將下載的 nginx-1.24.0.tar.gz
放到 /root/to_install
1、在 /usr/local/
下建立 nginx
⽂件夾並進⼊
cd /usr/local/
mkdir nginx
cd nginx
2、將 Nginx 安裝包解壓到 /usr/local/nginx
中即可
tar zxvf /root/to_install/nginx-1.24.0.tar.gz -C ./
預先安裝額外依賴
yum -y install pcre-devel
yum -y install openssl openssl-devel
編譯安裝nginx
cd nginx-1.17.10
./configure
make && make install
安裝完成後nginx可執行檔案位於該目錄下
/usr/local/nginx/sbin/
如果想停⽌Nginx服務,可執⾏:
/usr/local/nginx/sbin/nginx -s stop
如果修改了配置⽂件後想重新載入Nginx,可執⾏:
/usr/local/nginx/sbin/nginx -s reload
配置檔案位於
/usr/local/nginx/conf/nginx.conf
驗證配置檔案
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
啟動nginx
/usr/local/nginx/sbin/nginx
伺服器上驗證
curl 127.0.0.1
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.24.0</center>
</body>
</html>