安装包:
链接:https://pan.baidu.com/s/16-iPpb2oKPKRLlFnJiEHLw
提取码:jd1g
//先把所有的压缩文件放在/usr/local/apps/ 然后切换到apps下
1.安装pcre
//解压缩pcre-xx.tar.gz包
[root@master apps]# tar -zxvf pcre-8.37.tar.gz
//进入解压缩目录,执行./configure
[root@master apps]# cd pcre-8.37
[root@master pcre-8.37]# ./configure
//如果提示,需要提前安装gcc++ 进入安装光盘目录的软件包(/media/CentOSXX/Package)
//执行两条命令:
// rpm -ivh libstdc++-devel-4.4.7-17.el6.x86_64.rpm
// rpm -ivh gcc-c++-4.4.7-17.el6.x86_64.rpm
//我之前安装过,跳过这一步;
//./configure完成后,回到pcre目录下执行make,再执行make install
[root@master pcre-8.37]# make
[root@master pcre-8.37]# make install
2. 安装openssl
//解压缩openssl-xx.tar.gz包。
[root@master apps]# tar -zxvf openssl-1.0.1t.tar.gz
// 进入解压缩目录,执行./config
[root@master apps]# cd openssl-1.0.1t
[root@master openssl-1.0.1t]# ./config
//make && make install
[root@master openssl-1.0.1t]# make && make install
3. 安装zlib
//1、 解压缩zlib-xx.tar.gz包。
[root@master apps]# tar -zxvf zlib-1.2.8.tar.gz
//2、 进入解压缩目录,执行./configure。
[root@master apps]# cd zlib-1.2.8.tar.gz
[root@master zlib-1.2.8]# ./configure
//3、 make && make install
[root@master zlib-1.2.8]# make && make install
4. 安装nginx
//1、 解压缩nginx-xx.tar.gz包。
[root@master apps]# tar -zxvf nginx-1.11.1.tar.gz
//2、 进入解压缩目录,执行./configure。
[root@master apps]# cd nginx-1.11.1
[root@master nginx-1.11.1]# ./configure
//3、 make && make install
[root@master nginx-1.11.1]# make && make install
//已经成成功装完了,到local下会看到nginx
[root@master local]# pwd
/usr/local
[root@master local]# ls
apps bin etc games include lib lib64 libexec nginx sbin share src ssl tools
5.启动命令:
//在/usr/local/nginx/sbin目录下 执行 ./nginx
[root@master sbin]# ./nginx
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
//报错了,centos6.8及以下版本会报这个错,解决办法如下,粘贴复制执行即可:
[root@master sbin]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@master sbin]# ./nginx
//查看已经成功启动!!!!
[root@master sbin]# ps aux | grep nginx
root 21780 0.0 0.0 19920 632 ? Ss 06:50 0:00 nginx: master process ./nginx
nobody 21781 0.0 0.0 20348 1228 ? S 06:50 0:00 nginx: worker process
root 21783 0.0 0.0 103256 844 pts/0 S+ 06:51 0:00 grep nginx
6.关闭命令:
//在/usr/local/nginx/sbin目录下 执行 ./nginx -s stop
[root@master sbin]# ./nginx -s stop
//查看确实关闭了!!!
[root@master sbin]# ps aux | grep nginx
root 21790 0.0 0.0 103256 844 pts/0 S+ 06:53 0:00 grep nginx
7.重新加载命令:
// 在/usr/local/nginx/sbin目录下 执行 ./nginx -s reload 注意的是的启动前提下,才能执行这个命令
[root@master sbin]# ./nginx -s reload
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
[root@master sbin]# ./nginx
[root@master sbin]# ./nginx -s reload
8.番外篇:设置linux下开机就启动nginx:
修改linux 启动脚本/etc/rc.d/rc 加入 : /usr/local/nginx/sbin/nginx