Linux Ubuntu 阿里云服务器配置

原创
2014/07/17 10:29
阅读数 495

服务器配置记录,分享给大家 全新服务器,Linux Ubuntu 阿里云服务器,4核,16G内存,一块300G硬盘, 1,挂载硬盘 2,安装基础支持 3,安装jdk 4,安装nginx 5,安装redis


  • 前序准备

更新服务器

<!-- lang: shell -->
apt-get update 
apt-get dist-upgrade
reboot

挂载硬盘

<!-- lang: shell -->
    fdisk /dev/xvdb << EOF
    n
    p
    1
    
    
    wq
    EOF
    
    
    mkfs.ext4 /dev/xvdb
    if [ -e /alidata ]
    then
    exit;
    fi
    mkdir /alidata
    
    echo '/dev/xvdb             /alidata                 ext4    defaults        1 2' >> /etc/fstab
    mount -a

安装基础支持

<!-- lang: shell -->
    cat >> /etc/sysctl.conf <<EOF
    
    fs.file-max=65535
    
    net.ipv4.tcp_timestamps = 0
    
    net.ipv4.tcp_synack_retries = 5
    
    net.ipv4.tcp_syn_retries = 5
    
    net.ipv4.tcp_tw_recycle = 1
    
    net.ipv4.tcp_tw_reuse = 1
    
    net.ipv4.tcp_fin_timeout = 30
    
    #net.ipv4.tcp_keepalive_time = 120
    
    net.ipv4.ip_local_port_range = 1024  65535
    
    kernel.shmall = 2097152
    
    kernel.shmmax = 2147483648
    
    kernel.shmmni = 4096
    
    kernel.sem = 5010 641280 5010 128
    
    net.core.wmem_default=262144
    
    net.core.wmem_max=262144
    
    net.core.rmem_default=4194304
    
    net.core.rmem_max=4194304
    
    net.ipv4.tcp_fin_timeout = 10
    
    net.ipv4.tcp_keepalive_time = 30
    
    net.ipv4.tcp_window_scaling = 0
    
    net.ipv4.tcp_sack = 0
    
    EOF
    
    sysctl -p

取消限制

<!-- lang: shell -->
    cat >> /etc/security/limits.conf <<EOF
    * soft nofile 65535
    * hard nofile 65535
    EOF

安装基础软件在此输入代码

<!-- lang: shell -->
    #! /bin/sh
    rm -rf libiconv-1.13.1.tar.gz libiconv-1.13.1 zlib-1.2.3.tar.gz zlib-1.2.3 freetype-2.1.10.tar.gz libpng-1.2.8.tar.gz libevent-1.4.14b.tar.gz libmcrypt-2.5.8.tar.gz
    groupadd www
    useradd -g www -M -d /data/www -s /sbin/nologin www
    
    if [ ! -f libiconv-1.13.tar.gz ];then
    	wget http://soft.phpwind.me/web/libiconv-1.13.1.tar.gz
    fi
    rm -rf libiconv-1.13.1
    tar zxvf libiconv-1.13.1.tar.gz
    cd libiconv-1.13.1
    ./configure --prefix=/usr/local
    make
    make install
    cd ..
    
    
    if [ ! -f zlib-1.2.3.tar.gz ];then
    	wget http://soft.phpwind.me/web/zlib-1.2.3.tar.gz
    fi
    rm -rf zlib-1.2.3
    tar zxvf zlib-1.2.3.tar.gz
    cd zlib-1.2.3
    ./configure
    make CFLAGS=-fpic
    make install
    cd ..
    
    
    if [ ! -f freetype-2.1.10.tar.gz ];then
    	wget http://soft.phpwind.me/web/freetype-2.1.10.tar.gz
    fi
    rm -rf freetype-2.1.10
    tar zxvf freetype-2.1.10.tar.gz
    cd freetype-2.1.10
    ./configure --prefix=/usr/local/freetype.2.1.10
    make
    make install
    cd ..
    
    
    if [ ! -f libpng-1.2.8-config.tar.gz ];then
    	wget http://soft.phpwind.me/web/libpng-1.2.8.tar.gz
    fi
    rm -rf libpng-1.2.8
    tar zxvf libpng-1.2.8.tar.gz
    cd libpng-1.2.8
    ./configure --prefix=/usr/local/libpng.1.2.8
    make CFLAGS=-fpic
    make install
    cd ..
    
    
    if [ ! -f libevent-1.4.14b-stable.tar.gz ];then
    	wget http://soft.phpwind.me/web/libevent-1.4.14b.tar.gz
    fi
    rm -rf libevent-1.4.14b
    tar zxvf libevent-1.4.14b.tar.gz
    cd libevent-1.4.14b
    ./configure
    make
    make install
    cd ..
    
    
    if [ ! -f libmcrypt-2.5.8.tar.gz ];then
    	wget http://soft.phpwind.me/web/libmcrypt-2.5.8.tar.gz
    fi
    rm -rf libmcrypt-2.5.8
    tar zxvf libmcrypt-2.5.8.tar.gz
    cd libmcrypt-2.5.8
    ./configure --disable-posix-threads
    make
    make install
    /sbin/ldconfig
    cd libltdl/
    ./configure --enable-ltdl-install
    make
    make install
    cd ../..
    
    
    if [ ! -f pcre-8.12.tar.gz ];then
    	wget http://soft.phpwind.me/web/pcre-8.12.tar.gz
    fi
    rm -rf pcre-8.12
    tar zxvf pcre-8.12.tar.gz
    cd pcre-8.12
    ./configure
    make && make install
    cd ..
    
    
    if [ ! -f jpegsrc.v6b.tar.gz ];then
    	wget http://soft.phpwind.me/web/jpegsrc.v6b.tar.gz
    fi
    rm -rf jpeg-6b
    tar zxvf jpegsrc.v6b.tar.gz
    cd jpeg-6b
    if [ -e /usr/share/libtool/config.guess ];then
    cp -f /usr/share/libtool/config.guess .
    elif [ -e /usr/share/libtool/config/config.guess ];then
    cp -f /usr/share/libtool/config/config.guess .
    fi
    if [ -e /usr/share/libtool/config.sub ];then
    cp -f /usr/share/libtool/config.sub .
    elif [ -e /usr/share/libtool/config/config.sub ];then
    cp -f /usr/share/libtool/config/config.sub .
    fi
    ./configure --prefix=/usr/local/jpeg.6 --enable-shared --enable-static
    mkdir -p /usr/local/jpeg.6/include
    mkdir /usr/local/jpeg.6/lib
    mkdir /usr/local/jpeg.6/bin
    mkdir -p /usr/local/jpeg.6/man/man1
    make
    make install-lib
    make install
    cd ..

安装jdk

<!-- lang: shell -->
apt-get install openjdk-7-jre

安装OpenSSL

<!-- lang: shell -->
   apt-get install libcurl4-openssl-dev

安装nginx

<!-- lang: shell -->
wget http://tengine.taobao.org/download/tengine-2.0.3.tar.gz
chmod 755 tengine-2.0.3.tar.gz
tar -xzvf  tengine-2.0.3.tar.gz
cd tengine-2.0.3
./configure --prefix=/alidata/server/nginx 
make
make install
/alidata/server/nginx/sbin/ningx

安装redis

<!-- lang: shell -->
wget http://download.redis.io/releases/redis-2.8.13.tar.gz
chmod 755 redis-2.8.13.tar.gz
tar -xzvf redis-2.8.13.tar.gz
cd redis-2.8.13
mv ./* /alidata/server/redis
cd /alidata/server/redis
make
make install
/alidata/server/redis/src/redis-server  /alidata/server/redis/redis.conf

完毕

展开阅读全文
打赏
0
4 收藏
分享
加载中
更多评论
打赏
0 评论
4 收藏
0
分享
返回顶部
顶部