链接:https://pan.baidu.com/s/1dXFiPPfya7W7Dea4qMmxAQ
提取码:ryuc
官网下载:http://nginx.org/download/
1:使用xftp上传nginx-1.12.0.tar.gz到/usr/local/mysoft目录下(我一般把软件都安装到/usr/local/mysoft目录下)
[root@myLinux /]# cd usr/local/mysoft/
[root@myLinux mysoft]# ls
apache-tomcat-7.0.93 jdk1.8.0_251 nginx-1.12.0.tar.gz redis-5.0.7 zookeeper-3.4.14
2:解压nginx压缩包 tar -zxvf nginx-1.12.0.tar.gz
[root@myLinux mysoft]# tar -zxvf nginx-1.12.0.tar.gz
[root@myLinux mysoft]# ls
apache-tomcat-7.0.93 jdk1.8.0_251 nginx-1.12.0 nginx-1.12.0.tar.gz redis-5.0.7 zookeeper-3.4.14
3:进入解压后的目录
[root@myLinux mysoft]# cd nginx-1.12.0 [root@myLinux nginx-1.12.0]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
4:执行./configure
[root@myLinux nginx-1.12.0]# ./configure checking for OS + Linux 3.10.0-514.26.2.el7.x86_64 x86_64 checking for C compiler ... found
5:有可能make失败,所以我们先安装前置库 yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel
[root@myLinux nginx-1.12.0]# yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel
6:make
[root@myLinux nginx-1.12.0]# make make -f objs/Makefile make[1]: Entering directory `/usr/local/mysoft/nginx-1.12.0' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs
7make install
[root@myLinux nginx-1.12.0]# make install make -f objs/Makefile install make[1]: Entering directory `/usr/local/mysoft/nginx-1.12.0' test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
8:cd /usr/local 进入/usr/local目录 发现该目录下多了一个nginx文件夹
[root@myLinux nginx-1.12.0]# cd /usr/local
[root@myLinux local]# ls
aegis bin etc games include lib lib64 libexec mysoft mysql nginx sbin share src
9:cd nginx/conf 进入nginx的conf目录下
[root@myLinux local]# cd nginx/conf [root@myLinux conf]# ls fastcgi.conf fastcgi_params.default mime.types nginx.conf.default uwsgi_params fastcgi.conf.default koi-utf mime.types.default scgi_params uwsgi_params.default fastcgi_params koi-win nginx.conf scgi_params.default win-utf
10:vim nginx.conf 编辑nginx配置文件内容,为防止端口占用,将listen后面的端口号改为8081,将sever_name后面的localhost换成自己的服务器的ip
server { listen 8081; server_name 11.97.188.188;
11: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx(关闭nginx pkill -9 nginx)
[root@myLinux conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf [root@myLinux conf]#
12:在浏览器地址栏中输入:ip:8081 出现nginx欢迎页说明安装并启动成功