1.准備工作
1)關閉iptables
關閉操作
iptables -t nat -F
查看操作
iptables -t nat -L
2)關閉selinux
查看操作
setenforce
關閉操作
setenforce 0
3)初始化
cd /opt;mkdir app download logs work backup
4)確認gcc yum源可用
yum list|grep gcc
5)兩項安裝
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make auromake
yum -y install wget httpd-tools vim
2.利用網絡,構建nginx的yum倉庫。
vim /etc/yum.repos.d/nginx.repo
然后 訪問http://nginx.org/en/linux_packages.html#stable
復制其中
[nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
修改成
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
完成后保存退出
3.yum install nginx 即可安裝完成
備注:
1)查看nginx編譯配置參數:nginx -V
2)查看nginx版本號:nginx-v
3) 查看nginx安裝目錄:rpm -ql nginx
4.查看nginx站點
這里需要設置防火牆開放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
重啟防火牆 systemctl start firewalld.service
備注: 關閉防火牆命令 systemctl stop firewalld.service
啟動nginx服務
nginx
重啟nginx服務
systemctl restart nginx.service
停止nginx服務
cp /etc/nginx/nginx.conf /opt/backup/nginx.conf
cp /etc/nginx/conf.d/default.conf /opt/backup/default.conf