Centos安装nginx
1、下载nginx
wget http://nginx.org/download/nginx-1.9.9.tar.gz
2、解压
tar zxvf nginx-1.9.9.tar.gz
3、安装PCRE库
sudo yum install pcre pcre-devel
4、安装zlib库
sudo yum install zlib-devel
5、进行编译
cd nginx-1.9.9
./configure
6、进行安装
make
7、启动nginx
/usr/local/nginx/sbin/nginx
8、启动后记得放开80端口并重新加载防火墙
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
9、关闭命令
/usr/local/nginx/sbin/nginx -s stop
使用yum命令安装
下载
sudo yum install epel-release
安装
sudo yum install nginx
运行方法
启动 Nginx:
sudo systemctl start nginx
停止 Nginx:
sudo systemctl stop nginx
重启 Nginx:
sudo systemctl restart nginx
放开80端口
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload