先安裝gcc-c++編譯器
yum install gcc-c++
yum install -y openssl openssl-devel
安裝pcre包
yum install -y pcre pcre-devel
安裝zlib包
yum install -y zlib zlib-devel
在/usr/local/創(chuàng)建nginx文件
mkdir /usr/local/nginx
進(jìn)入nginx目錄
cd /use/local/nginx
下載nginx安裝包
wget https://nginx.org/download/nginx-1.19.9.tar.gz
注:如果沒(méi)有wget命令,就安裝命令
yum install wget
解壓安裝包
tar -zxvf nginx-1.19.9.tar.gz
cd nginx-1.19.9
執(zhí)行以下三個(gè)命令
./configure
make
make install
添加到系統(tǒng)服務(wù)中
vim /etc/profile
最后加入配置
export PATH=/usr/local/nginx/sbin:$PATH
重載配置
source /etc/profile
添加systemctl命令
vi /usr/lib/systemd/system/nginx.service
添加內(nèi)容
[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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 stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加載系統(tǒng)服務(wù)
systemctl daemon-reload
啟動(dòng)服務(wù)
systemctl start nginx
停止服務(wù)
systemctl stop nginx
重啟服務(wù)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-787998.html
systemctl restart nginx
重載配置文件文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-787998.html
nginx -s reload
到了這里,關(guān)于linux安裝nginx,配置系統(tǒng)文件,配置systemctl命令,親測(cè)可用,的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!