实验环境:centos7.2,已安装httpd,80端口被占用。nginx
编辑httpd配置文件:apache
# vim /etc/httpd/conf/httpd.conf
找到Listen,修改httpd监听端口:vim
重启apache服务:centos
# systemctl restart httpd.service
安装nginx:bash
# yum -y install nginx
nginx安装成功,验证配置文件及端口:服务器
# nginx -t
若是安装完成之后80端口被占用了,即便怎么中止占用80端口的应用,甚至删除应用,nginx -t都会提示 nginx: [emerg] socket() [::]:80 failed (97: Address family not supported bysocket
解决办法是修改配置文件:(# vim /etc/nginx/conf.d/default.conf)ide
listen 80 default_server; listen [::]:80 default_server;
改为:测试
listen 80 default_server; #listen [::]:80 default_server;
设置开机自动启动:centos7
# systemctl enable nginx.service
启动nginx服务器&查看nginx当前状态:
域名测试:
公网ip测试: