1.1、安装 OpenSSL(方法自行搜索)
1.2、准备 pcre 库 pere 是为了让 nginx 支持正则表达式。只是准备,并不安装,是为了避免在64位系统中出现错误。
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
tar -zxf pcre-8.30
wget
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz tar -zxf pcre-8.30
|
wget http://sourceforge.net/projects/libpng/files/zlib/1.2.6/zlib-1.2.6.tar.gz/download
tar -zxf zlib-1.2.6.tar.gz
wget
http://sourceforge.net/projects/libpng/files/zlib/1.2.6/zlib-1.2.6.tar.gz/download tar -zxf zlib-1.2.6.tar.gz
|
wget http://nginx.org/download/nginx-1.1.9.tar.gz
tar -zxf nginx-1.1.9.tar.gz
cd nginx-1.1.9
mkdir -p /var/tmp/nginx
wget http://nginx.org/download/nginx-1.1.9.tar.gz tar -zxf nginx-1.1.9.tar.gz cd nginx-1.1.9 mkdir -p /var/tmp/nginx
|
./configure --prefix=/usr/local/nginx
--pid-path=/var/run/nginx.pid
--lock-path=/var/lock/nginx.lock
--with-http_ssl_module
--with-http_dav_module
--with-http_flv_module
--with-http_realip_module
--with-http_gzip_static_module
--with-http_stub_status_module
--with-mail --with-mail_ssl_module
--with-pcre=../pcre-8.30
--with-zlib=../zlib-1.2.6
--with-debug
--http-client-body-temp-path=/var/tmp/nginx/client
--http-proxy-temp-path=/var/tmp/nginx/proxy
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
--http-scgi-temp-path=/var/tmp/nginx/scgi
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre=../pcre-8.30 --with-zlib=../zlib-1.2.6 --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi make && make install ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
|
–prefix #nginx安装目录,默认在/usr/local/nginx
–pid-path #pid问件位置,默认在logs目录
–lock-path #lock问件位置,默认在logs目录
–with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
–with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
–with-http_flv_module #支持对FLV文件的拖动播放
–with-http_realip_module #支持显示真实来源IP地址
–with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
–with-http_stub_status_module #取得一些nginx的运行状态
–with-mail #允许POP3/IMAP4/SMTP代理模块
–with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
–with-pcre=../pcre-8.11 #注意是未安装的pcre路径
–with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径
–with-debug #允许调试日志
–http-client-body-temp-path #客户端请求临时文件路径
–http-proxy-temp-path #设置http proxy临时文件路径
–http-fastcgi-temp-path #设置http fastcgi临时文件路径
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
–http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径
2.3、开机自启动 nginx 脚本
进入编辑模式,键入以下脚本内容:
#!/bin/bash
#
#chkconfig: - 85 15
#description: Nginx is a World Wide Web server.
#processname: nginx
nginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx/conf/nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done"
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done"
;;
test)
$nginx -t -c $conf
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done"
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep nginx
;;
*)
echo -n "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac
#!/bin/bash
#
#chkconfig: - 85 15
#description: Nginx is a World Wide Web server.
#processname: nginx
nginx=/usr/local/nginx/sbin/nginx
conf=/usr/local/nginx/conf/nginx.conf
case $1 in
start)
echo -n "Starting Nginx"
$nginx -c $conf
echo " done"
;;
stop)
echo -n "Stopping Nginx"
killall -9 nginx
echo " done"
;;
test)
$nginx -t -c $conf
;;
reload)
echo -n "Reloading Nginx"
ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP
echo " done"
;;
restart)
$0 stop
$0 start
;;
show)
ps -aux|grep nginx
;;
*)
echo -n "Usage: $0 {start|restart|reload|stop|test|show}"
;;
esac
保存以上脚本后,执行以下操作
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
chmod +x /etc/init.d/nginx chkconfig --add nginx chkconfig nginx on
|
附录:nginx虚拟主机配置
server {
listen 80;
server_name vps.xj123.info;
location / {
root html/vps;
index index.html index.htm;
}
}
server { listen 80; server_name vps.xj123.info; location / { root html/vps; index index.html index.htm; } }
|