说在前面:
最近新搞了一台香港主机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 /tmp wget wget http://oss.aliyuncs.com/aliyunecs/onekey/nginx/nginx-1.4.4.tar.gz
建立服务用户:
groupadd www useradd -g www -M -d /alidata/www -s /usr/sbin/nologin www
设置路径并解压:
mkdir -p /alidata mkdir -p /alidata/server mkdir -p /alidata/www mkdir -p /alidata/log mkdir -p /alidata/log/nginx mkdir -p /alidata/log/nginx/access chown -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_NUM else make fi make install
cd ..
复制配置文件并启动:
#处理器个数
CPU_NUM=1 cp -fR ./nginx/config-nginx/* /alidata/server/nginx/conf/ sed -i 's/worker_processes 2/worker_processes '"$CPU_NUM"'/' /alidata/server/nginx/conf/nginx.conf chmod 755 /alidata/server/nginx/sbin/nginx mv /alidata/server/nginx/conf/nginx /etc/init.d/ chmod +x /etc/init.d/nginx /etc/init.d/nginx start