1. 直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html, 下载nginx-1.13.7.tar.gz
使用wget命令下载
wget -c http://nginx.org/download/nginx-1.13.7.tar.gz
2. 解压
[root@local tools]# tar -zxvfnginx-1.13.7.tar.gz
3. 进入解压后的目录
[root@local tools]# cd nginx-1.13.7
4.编译安装
[root@local nginx-1.13.7]# ./configure
[root@local nginx-1.13.7]# make
[root@local nginx-1.13.7]# make install
5. 开端口
[root@local nginx-1.13.7]# firewall-cmd --state
not running
[root@local nginx-1.13.7]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@local nginx-1.13.7]# firewall-cmd --zone=public--add-port=80/tcp --permanent
success
[root@local nginx-1.13.7]# firewall-cmd --permanent--list-port
80/tcp
[root@local nginx-1.13.7]# service firewalld restart
Redirecting to /bin/systemctl restart firewalld.service
[root@local nginx-1.13.7]# systemctl stopfirewalld.service
6. 启动,关闭nginx
查看安装位置:[root@local nginx-1.13.7]# whereis nginx
nginx: /usr/local/nginx
[root@local nginx-1.13.7]# cd /usr/local/nginx/sbin/
启动:[root@local sbin]# ./nginx
停止:[root@local sbin]# ./nginx -s stop
7. 安装过程中,有可能需要安装依赖项:
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
8. 命令执行顺序一般如下:
tar -zxvf nginx-1.13.7.tar.gz
cd nginx-1.13.7
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
./configure
make
make install
firewall-cmd --state
service firewalld restart
firewall-cmd --zone=public --add-port=80/tcp--permanent
firewall-cmd --permanent --list-port
service firewalld restart
systemctl stop firewalld.service
ps aux|grep nginx
whereis nginx
cd /usr/local/nginx/sbin/
./nginx
./nginx-s stop