安装Nginx
yum install nginx
正常情况下必定是:
已加载插件:fastestmirror, langpacksbase | 3.6 kB 00:00:00 docker-main | 2.9 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/2): extras/7/x86_64/primary_db | 122 kB 00:00:00 (2/2): updates/7/x86_64/primary_db | 2.9 MB 00:00:28 Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com没有可用软件包 nginx。错误:无须任何处理
遂百度查找,
#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
a、先创建一个yum的一个repository文件:/etc/yum.repos.d/nginx.repo;
b、然后将下面配置粘贴进文件后保存。
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
接下来基本上就顺了:
(1)安装Nginx#yum install nginx(2)启动Nginx#service nginx start或#systemctl start nginx.service
访问一下:
curl http://127.0.0.1
Welcome to nginx! Welcome to nginx!
If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.
For online documentation and support please refer tonginx.org.
Commercial support is available atnginx.com.Thank you for using nginx.
本机访问虚拟机ip:
ps:如果访问失败
1、可能是防火墙的问题:
关闭防火墙 service iptables stop
2、也可能是80端口没有打开:
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT