说在前面:
最近新搞了一台香港主机ubuntu系统,搞搞机,全新安装什么环境也没有,捣鼓捣鼓吧!
安装依赖库:
apt-get -y update apt-get install libxml2-dev openssl libjpeg-dev libpng-dev libcurl3-openssl-dev libfreetype6-dev libxslt-dev apt-get -y install --only-upgrade bash
先把这一对装上吧万一用得到呐
指定下载目录并下载源码:
cd /tmpwget wget http://oss.aliyuncs.com/aliyunecs/onekey/nginx/nginx-1.4.4.tar.gz
建立服务用户:
groupadd wwwuseradd -g www -M -d /alidata/www -s /usr/sbin/nologin www
设置路径并解压:
mkdir -p /alidatamkdir -p /alidata/servermkdir -p /alidata/wwwmkdir -p /alidata/logmkdir -p /alidata/log/nginxmkdir -p /alidata/log/nginx/accesschown -R www:www /alidata/log chmod 775 /alidata/server/nginx/logs chown -R www:www /alidata/server/nginx/logs chmod -R 775 /alidata/www chown -R www:www /alidata/www tar zxvf nginx-1.4.4.tar.gz cd nginx-1.4.4
编译:
./configure --user=www \--group=www \--prefix=/alidata/server/nginx \--with-http_stub_status_module \--without-http-cache \--with-http_ssl_module \--with-http_gzip_static_module
安装:
CPU_NUM=$(cat /proc/cpuinfo | grep processor | wc -l)if [ $CPU_NUM -gt 1 ];then make -j$CPU_NUMelse makefimake install cd ..
复制配置文件并启动:
#处理器个数 CPU_NUM=1cp -fR ./nginx/config-nginx/* /alidata/server/nginx/conf/sed -i 's/worker_processes 2/worker_processes '"$CPU_NUM"'/' /alidata/server/nginx/conf/nginx.confchmod 755 /alidata/server/nginx/sbin/nginxmv /alidata/server/nginx/conf/nginx /etc/init.d/chmod +x /etc/init.d/nginx/etc/init.d/nginx start