nginx 的安装
yum 安装
nginx 官网 yum 源配置
vim /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
module_hotfixes=true
yum info nginx
yum --enablerepo=epel info nginx
yum --enablerepo=epel install nginx -y
相关文件
/usr/share/nginx/html/index.html
/etc/nginx/nginx.conf
/usr/lib64/nginx/modules
/usr/lib/systemd/system/nginx.service
/usr/sbin/nginx
systemctl start nginx
echo welcome to www.xuepeng.com > /usr/share/nginx/html/index.html
systemctl stop nginx
nginx命令
ngix //启动服务
-v // 显示版本信息
-V // 显示版本号,configure的编译选项
-t //检测语法
-T //l输出配置项
-q //非错误的消息不显示
-s stop|quit|reopen|reload
-p //指定工作目录
-c //指定配置文件
-g //指定一个配置的指令修改配置文件
注意
- 用 nginx 命令启动服务,不能用 systemctl stop nginx 停掉服务
- 用 systemctl start nginx 命令启动的服务,可以用 nginx -s stop 命令停掉服务
编译安装 nginx
yum install pcre-devel openssl-devel zlib-devel gcc -y
useradd -r -s /sbin/nologin nginx
tar xvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
make -j4 && make install
ln -s /apps/nginx/sbin/nginx /usr/sbin/
chown -R nginx.nginx /apps/nginx/
echo "/usr/sbin/nginx" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local