linux 安装nginx 开机自启

一、安装nginx

1.

到【nginx: download】下载,上传压缩包到非【/usr/local/】目录

解压:

tar -zxvf nginx-1.20.2.tar.gz -C /

2.

cd nginx-1.20.2

3.

./configure --prefix=/usr/local/nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module

#配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态。

如果执行后报错

./configure: error: the HTTP rewrite module requires the PCRE library.

则执行语句,安装

yum -y install pcre-devel

如果执行后报错

./configure: error: SSL modules require the OpenSSL library.

则执行语句,安装

yum -y install openssl openssl-devel

4.

make & make install

5.

cd /usr/local/nginx-1.20.2/sbin/

二、添加开机自启

1.

vim /etc/rc.local

2.

在文档底部添加

/usr/local/nginx-1.20.2/sbin/nginx

3.

执行语句

chmod +x /etc/rc.d/rc.local

使/etc/rc.d/rc.local变成可执行文件。

ps:一些命令

cd到sbin目录下

启动———./nginx

检验规则———./nginx -t

重启———./nginx -s reload

验证nginx是否启动

ps -ef | grep nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值