第一步:环境准备
环境准备:CentOS 6.5 、nginx-1.9.14.tar.gz
安装目录:mkdir /usr/local/nginx --nginx-1.9.14.tar.gz
mkdir /usr/local/zlib --zlib-1.2.8.tar.gz
mkdir /usr/local/openssl --openssl-1.0.1s.tar.gz
mkdir /usr/local/pcre --pcre-8.38.tar.gz
第二步:安装nginx
1.解压缩nginx-1.9.14.tar.gz
[root@node1 nginx]# tar -zxvf nginx-1.9.14.tar.gz
2.进入 nginx-1.9.14
cd nginx-1.9.14
3.在安装 nginx-1.9.14之前还需安装
安装zlib-1.2.8.tar.gz
[root@node1 zlib]# tar -zxvf zlib-1.2.8.tar.gz
[root@node1 zlib-1.2.8]# ./configure --prefix=/usr/local/zlib/
[root@node1 zlib-1.2.8]# make && make install
安装:openssl-1.0.1s.tar.gz
[root@node1 openssl]tar -zxvf openssl-1.0.1s.tar.gz
[root@node1 openssl-1.0.1s] ./config --prefix=/usr/local/openssl/
[root@node1 openssl-1.0.1s] make && make install
安装:pcre-8.38.tar.gz
[root@node1 pcre]tar -zxvf pcre-8.38.tar.gz
[root@node1 pcre-8.38]./config --prefix=/usr/local/pcre/
[root@node1 pcre-8.38]make && make install
4.安装nginx-1.9.14.tar.gz
[root@node1 nginx-1.9.14]# ./configure
[root@node1 nginx-1.9.14]# make && make install
安装成功启动nginx 服务
[root@node2 sbin]# ./nginx
注意:如果安装过程遇到下面的错误:
测试http://ip/localhost:80/如果出现
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
表示安装成功了
第三步:如何修改nginx端口
1.先查询nginx是否启动
查看nginx进程 ps -ef|grep nginx
[root@node2 sbin]# ps -ef|grep nginx
root 34886 1 0 Apr13 ? 00:00:00 nginx: master process ./nginx
nobody 34887 34886 0 Apr13 ? 00:00:00 nginx: worker process
root 36531 1871 0 01:56 pts/0 00:00:00 grep nginx
root 34886 1 0 Apr13 ? 00:00:00 nginx: master process ./nginx
nobody 34887 34886 0 Apr13 ? 00:00:00 nginx: worker process
root 36531 1871 0 01:56 pts/0 00:00:00 grep nginx
如果启动:
[root@node2 sbin]# pkill -9 nginx --停止所有的进程 然后修改端口
[root@node2 sbin] vi /usr/local/nginx/conf/nginx.conf
修改端口:
vi /usr/local/nginx/conf/nginx.conf
重启:
[root@node2 sbin]# ./nginx
如有不对的地方 请各位见谅