Centos安装nginx反向代理服务器

实验环境:centos7.2,已安装httpd,80端口被占用。nginx


编辑httpd配置文件:apache

# vim /etc/httpd/conf/httpd.conf


找到Listen,修改httpd监听端口:vim

wKioL1jhE-KTyoaaAAAyN08U2Vw830.png

重启apache服务:centos

# systemctl restart httpd.service


安装nginx:bash

# yum -y install nginx


nginx安装成功,验证配置文件及端口:服务器

# nginx -t

wKiom1jhFofRHGIrAAAWuOwxvs4883.png


若是安装完成之后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

wKiom1jhGIbyDcWGAAAW4IMB6Iw056.png


启动nginx服务器&查看nginx当前状态:

wKioL1jhGIbjpJm0AACr9_IgQTs147.png


域名测试:

wKiom1jhGkHQBWqkAAC9P2NUEwM586.png


公网ip测试:

wKioL1jhG0ngDv3IAAB7Pk35HXM684.png

相关文章
相关标签/搜索