nginx源码包安装
nginx安裝
CentOS
你可以在你的 CentOS 系統中添加 openresty 倉庫,這樣就可以便于未來安裝或軟件包(通過 yum check-update 命令)。 運行下面的命令就可以添加我們的倉庫(對于 CentOS 8 或以上版本,應將下面的 yum 都替換成 dnf):
add the yum repo:
wget https://openresty.org/package/centos/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
update the yum index:
sudo yum check-update
然后就可以像下面這樣安裝軟件包,比如 openresty:
sudo yum install -y openresty
如果你想安裝命令行工具 resty,那么可以像下面這樣安裝 openresty-resty 包:
sudo yum install -y openresty-resty
命令行工具 opm 在 openresty-opm 包里,而 restydoc 工具在 openresty-doc 包里頭。
列出所有 openresty 倉庫里頭的軟件包:
sudo yum --disablerepo=“*” --enablerepo=“openresty” list available
開始安裝
1、下載nginx源碼安裝包
wget http://nginx.org/download/nginx-1.22.0.tar.gz
2、解壓安裝
tar -zxvf nginx-1.22.0.tar.gz
3、下載依賴庫
yum -y install pcre pcre-devel zlib zlib-devel
4、編譯安裝
./configure
make
make install
或者 使用 && 符號一起執行
./configure && make && make install
5、啟動nginx
cd /usr/local/nginx/sbin/
./nginx 啟動
./nginx -s stop 停止
./nginx -s quit 在退出前完成已經接受的連接請求
./nginx -s reload 重新加載配置
6、設置nginx使用systemctl命令操作
vim /usr/lib/systemd/system/nginx.service
[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
設置開機啟動
#systemctl enable nginx.service
啟動nginx服務
#systemctl start nginx.service
重新啟動nginx服務
#systemctl restart nginx.service
停止ngixn服務
#systemctl stop nginx.service
然后重新加載系統服務
systemctl daemon-reload
總結
以上是生活随笔為你收集整理的nginx源码包安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 河北省对口计算机打字试题,河北省对口升学
- 下一篇: Java编译器IDE-文本编辑器