• -------------------------------------------------------------
  • ====================================

centos7通过yum安装nginx

nginx_lua dewbay 5年前 (2019-09-02) 2373次浏览 已收录 0个评论 扫描二维码
yum install -y nginx

通过yum安装的时候提示下面的错误

[root@localhost yum.repos.d]# yum install nginx
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
没有可用软件包 nginx。
错误:无须任何处理

需要添加 nginx 的源

[root@localhost yum.repos.d]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

该命令执行之后,会在/etc/yum.respos.d 下面多出一个 nginx.repo

[root@localhost yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 1572 12 月  1 2016 CentOS-Base.repo
-rw-r--r--. 1 root root 1572 12 月  1 2016 CentOS-Base.repo.backup
-rw-r--r--. 1 root root 1664 10 月 24 10:36 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 8 月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8 月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8 月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 8 月  30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8 月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8 月  30 2017 CentOS-Vault.repo
-rw-r--r--. 1 root root  113 7 月  15 2014 nginx.repo

然后再执行安装命令

yum install -y nginx

安装之后,可以查看 nginx 的默认安装目录

[root@localhost yum.repos.d]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
[root@localhost yum.repos.d]# pwd
/etc/yum.repos.d

以下是Nginx的默认路径:

(1) Nginx配置路径:/etc/nginx/

(2) PID 目录:/var/run/nginx.pid

(3) 错误日志:/var/log/nginx/error.log

(4) 访问日志:/var/log/nginx/access.log

(5) 默认站点目录:/usr/share/nginx/html

事实上,只需知道Nginx配置路径,其他路径均可在/etc/nginx/nginx.conf 以及/etc/nginx/conf.d/default.conf 中查询到

nginx 相关的验证命令及启动命令

[root@localhost yum.repos.d]# nginx                    
[root@localhost yum.repos.d]# nginx -t                   
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost yum.repos.d]# nginx -s reload             

nginx   启动

nginx -t  测试命令

nginx -s relaod 修改 nginx.conf 之后,可以重载

 

参考:http://www.itmuch.com/install/nginx-yum-install-in-centos7/


露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:centos7通过yum安装nginx
喜欢 (0)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址