1. 安装方式:

有源码安装和yum安装两种方式。源码安装需要编译,设置安装目录。yum安装需要安装一些依赖的组件,目录分布在不同的地方。

yum安装之后的目录详解

            路径                                                 类型                                                    作用  

/etc/logrotate.d/nginx                             配置文件                                        nginx日志轮转,用于logrotate服务的日志切割

-----------------------------------------------------------------------------------------------------------------------------

/etc/nginx/

etc/nginx/conf.d                                   目录、配置文件                                    nginx主配置文件

/etc/nginx/conf.d/default.conf

/etc/nginx/nginx.conf

------------------------------------------------------------------------------------------------------------------------------

/etc/nginx/fastcgi_params

/etc/nginx/scgi_params                        配置文件                                        cgi配置相关,fastcgi配置

/etc/nginx/uwsgi_params

------------------------------------------------------------------------------------------------------------------------------

/etc/nginx/koi-utf
/etc/nginx/koi-win                                配置文件                                        编码转换映射转化文件(很少用到)
/etc/nginx/win-utf
------------------------------------------------------------------------------------------------------------------------------

/etc/nginx/mime.types                        配置文件                                       设置HTTP协议的Content-Type与拓展名对应关系

------------------------------------------------------------------------------------------------------------------------------

/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug                              配置文件                      用于配置出系统守护进程管理器的管理方式      
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
------------------------------------------------------------------------------------------------------------------------------

/usr/lib64/nginx/modules                            目录

/etc/nginx/modules                                                                            Nginx目录模块

------------------------------------------------------------------------------------------------------------------------------

/usr/sbin/nginx                                            命令                            Nginx服务的启动管理的终端命令
/usr/sbin/nginx-debug

------------------------------------------------------------------------------------------------------------------------------

/usr/share/doc/nginx-1.15.0                        文件、目录

/usr/share/doc/nginx-1.15.0/COPYRIGHT

/usr/share/man/man8/nginx.8.gz                                                    Nginx的手册和帮助文件

------------------------------------------------------------------------------------------------------------------------------

/var/cache/nginx                                            目录                                Nginx的缓存目录

------------------------------------------------------------------------------------------------------------------------------

/var/log/nginx                                                目录                                Nginx的日志目录

------------------------------------------------------------------------------------------------------------------------------

 

 

在访问的时候,如果出现403错误,403错误是一种在网站访问过程中,常见的错误提示,表示资源不可用。服务器理解客户的请求,但拒绝处理它,通常由于服务器上文件或目录的权限设置导致的WEB访问错误。在nginx.conf第一行user xxx改成服务器用户名即可。

重新启动服务

sudo systemctl restart nginx

如果开启了防火墙,需要添加端口才能在主机访问:

1.查看开发的端口
sudo firewall-cmd --zone=public --list-ports
2.添加端口
firewall-cmd --zone=public --add-port=2345/tcp --permanent //2345改成要添加的端口,permanent表示永久生效
2.更新防火墙
sudo firewall-cmd --reload

补充:Centos关闭防火墙

sudo systemctl stop firewalld 临时关闭

sudo systemctl disable firewalld ,然后reboot 永久关闭

sudo systemctl status  firewalld 查看防火墙状态。