CentOS7.0安装Nginx
安装Nginx
yum install nginx
正常情况下必定是:
已加载插件:fastestmirror, langpacks base | 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。 错误:无须任何处理
遂百度查找,CentOS7系统库中默认是没有Nginx的rpm包的,所以我们自己需要先更新下rpm依赖库。。。
#rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
还是去Nginx官网看了下官方的说法,点击这里(Install|NGINX)。
a、先创建一个yum的一个repository文件:/etc/yum.repos.d/nginx.repo;
b、然后将下面配置黏贴进文件后保存。
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
接下来基本上就顺了。
(1)安装Nginx #yum install nginx (2)启动Nginx #service nginx start 或 #systemctl start nginx.service
测试一下是否正常。
curl http://127.0.0.1
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>