nginx 的安装

nginx 的安装

yum 安装

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 //指定一个配置的指令修改配置文件

在这里插入图片描述
注意

  1. 用 nginx 命令启动服务,不能用 systemctl stop nginx 停掉服务
  2. 用 systemctl start nginx 命令启动的服务,可以用 nginx -s stop 命令停掉服务

编译安装 nginx

nginx-1.16.1.tar.gz

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值