yum源安装nginx
-
更新系统
# EPEL是一个由特别兴趣小组创建、维护并管理的,针对红帽企业版 Linux(RHEL)及其衍生发行版(比如 CentOS、Scientific Linux、Oracle Enterprise Linux)的一个高质量附加软件包项目. #EPEL 是yum的一个软件源,里面包含了许多基本源里没有的软件。安装上EPEL的源后,就可以直接用yum来安装软件,而且EPEL不会替换原有的源,安装后会产生新repo,省去了不少麻烦。 yum install epel-release -y yum update -
安装yum-utils
#yum-utils是yum的工具包集合,由不同的作者开发,使yum使用起来更加方便和强大。 yum -y install yum-utils -
编辑yum源
#新建文件 vi /etc/yum.repos.d/nginx.repo #文件内容 [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key -
查看yum源
yum list | grep nginx -
yum安装nginx
yum install nginx -
查看nginx的版本
nginx -v -
查看编译参数
nginx -V #参数内容 nginx version: nginx/1.14.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (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' -
安装目录查看
rpm -ql nginx -
查看配置文件
more /etc/nginx/nginx.conf -
检查配置文件语法是否正确
nginx -tc /etc/nginx/nginx.conf -
重载nginx服务
nginx -s reload -c /etc/nginx/nginx.conf -
nginx操作
# 开启nginx systemctl start nginx #关闭nginx systemctl stop nginx # 重启nginx systemctl reload nginx # 查看nginx状态 systemctl status nginx