【nginx】配置开机自启
1.nginx配置开机自启
vim /lib/systemd/system/nginx.service
[ Unit]
Description = nginx
After = network.target
[ Service]
Type = forking
ExecStart = /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload = /usr/local/nginx/sbin/nginx -s reload
ExecStop = /usr/local/nginx/sbin/nginx -s quit
PrivateTmp = true
[ Install]
WantedBy = multi-user.target
设置开机自启
systemctl enable nginx.service
systemctl start nginx.service
systemctl status nginx.service
2 、 下载Nginx安装包
wget http://nginx.org/download/nginx-1.27.0.tar.gz
2.1 解压Nginx压缩包
tar zxvf nginx-1.27.0.tar.gz
2.2 进入Nginx目录下
cd /nginx/nginx-1.27.0
2.3 配置安装运行目录
./configure --prefix = /usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
2.4 出现如下错误需要安装依赖包
yum -y install pcre-devel
yum -y install openssl openssl-devel
- 用以下命令下载gcc编译器
yum -y install gcc gcc-c++ autoconf automake make
2.5 进行重新配置
./configure --prefix = /usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
2.6 执行编译安装
make && make install
2.7 安装完毕,进入Nginx下的sbin目录并启动nginx
cd /usr/local/nginx/sbin
./nginx
启动、停止的几个命令
cd /usr/local/nginx/sbin
./nginx
或
./nginx -c /usr/local/nginx/conf/nginx.conf
./nginx -s stop
./nginx -s quit
./nginx -s reload