centos 安装nginx

1.根据nginx 官网安装步骤来安装 http://nginx.org/en/linux_packages.html
新建文件 vi /etc/yum.repos.d/nginx.repo
里面输入一下内容
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
里面OS 替换为centos OSRELEASE替换为7 $basearch 替换为x86_64
2.查看自己系统版本
rpm -qa | grep centos-release
3.通过yum install nginx 来安装nginx
4.启动nginx 命令
systemctl start nginx
5.查看nginx是否启动
netstat -ntl

image.png

如果看到这样说明启动成功
6.本地测试
curl -i localhost
如果显示如下
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Wed, 09 May 2018 07:47:07 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 17 Apr 2018 15:48:00 GMT
Connection: keep-alive
ETag: "5ad61730-264"
Accept-Ranges: bytes




Welcome to nginx!



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.




说明nginx安装成功
6.防火墙端口开发
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
7.如果是阿里云服务器还需要去管理后台安全组去添加开放80端口

你可能感兴趣的:(centos 安装nginx)