您的位置:首页 > 运维架构 > Nginx

centOS7安装Nginx

2017-10-17 11:40 423 查看
一、在线安装

方法/步骤

1.下载对应当前系统版本的nginx包(package)

# wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.建立nginx的yum仓库

# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

3.下载并安装nginx

# yum install nginx

4.启动nginx服务

systemctl start nginx

5.配置

默认的配置文件在 /etc/nginx 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf 和/conf.d/default.conf等文件即可。

如果80端口被占用,在另开一个端口命令如下:

设置centos7的自带防火墙端口号对外部开启

firewall-cmd --zone=public --add-port=8080/tcp --permanent

重启防火墙

systemctl restart firewalld.service

修改配置文件

vi /etc/nginx/conf.d/default.conf

将80端口改为8080端口

退出并保存

重启Nginx服务器

systemctl restart nginx.service

6.测试

在浏览器地址栏中,输入部署nginx环境的机器的IP,如果一切正常,应该能看到如下字样的内容,表示正常。

         Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.

Commercial support is available at nginx.com.

Thank you for using nginx.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: