今天准备在centos服务器上安装nginx.参考官方http://nginx.org/en/linux_packages.html#RHEL-CentOS
- sudo yum install yum-utils
2.创建 /etc/yum.repos.d/nginx.repo
内容如下:
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
3. sudo yum-config-manager --enable nginx-mainline
出现了个错误:File "/bin/yum-config-manager", line 135
原因是python 升级到3.6.8,修改yum-config-manager 第一行
!/usr/bin/python -tt 改为python2
- sudo yum install nginx
When prompted to accept the GPG key, verify that the fingerprint matches 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62, and if so, accept it.
已安装: nginx.x86_64 1:1.17.0-1.el7.ngx
nginx及其模块的工作方式在配置文件中确定。默认情况下,配置文件被命名nginx.conf 并放在目录/usr/local/nginx/conf,/etc/nginx,或 /usr/local/etc/nginx。
nginx -s signal
signal:
stop — fast shutdown 如:nginx -s stop
quit — graceful shutdown
reload — reloading the configuration file
reopen — reopening the log files
一、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的日志目录
nginx -V :会出现如下信息
nginx version: nginx/1.17.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'
-prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--modules-path=/usr/lib64/nginx/modules
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log 安装目录或者路径
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp 执行对应模块时,Nginx所保留的临时性文件
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx 设定Nginx的进程启动的用户和组用户
--with-cc-opt C语言编译
--with-ld-opt= 设置附加的参数,链接系统库