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