linux服务器安装nginx

#yum install nginx  安装nginx

如果无法安装nginx看下面的方法,可以就直接跳到下方启动nginx 

#rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

使用以上命令安装nginx库在使用第一条命令安装nginx

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.njupt.edu.cn * extras: mirrors.nju.edu.cn * updates: mirrors.nju.edu.cn Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:1.14.0-1.el6.ngx will be installed --> Processing Dependency: libpcre.so.0()(64bit) for package: nginx-1.14.0-1.el6.ngx.x86_64 --> Finished Dependency Resolution Error: Package: nginx-1.14.0-1.el6.ngx.x86_64 (nginx) Requires: libpcre.so.0()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest

如果安装出现上面的情况有2种可能:

1.没有网络可以试着ping www.baidu.com,看有没有网没有就没法下载了。

2.#sudo yum install epel-release

  #sudo yum install nginx

在对提示回答yes后,结尾出现Complete!     Nginx在服务器上完成安装。

  #nginx -v  查看nginx版本

  #rpm -ql nginx  查看nginx的安装目录

  #nginx -t    测试nginx的配置

  #sudo systemctl start nginx  启动nginx

 如果防火墙在运行中,执行以下命令

 #sudo firewall-cmd --permanent --zone=public --add-service=http

 #sudo firewall-cmd --permanent --zone=public --add-service=https

 #sudo firewall-cmd --reload

如果还不行就试下面的命令放行80端口

#iptables -A INPUT -p tcp --dport 80 -j ACCEPT

  如果想系统启动就运行nginx,可以执行以下命令

   #sudo systemctl enable nginx

接下来在浏览器输入服务器ip访问就可以了

猜你喜欢

转载自blog.csdn.net/weixin_42734930/article/details/81260792