ubuntu下nginx的配置
1.下載安裝包
sudo wget http://nginx.org/download/nginx-1.20.1.tar.gz 利用wget
下載wget sudo apt-get wget
2.解壓檔案指定目標路徑
tar -xvf nginx-1.20.1.tar.gz -c /usr/local
3.進入nginx.conf配置檔案 輸入命令配置檔案
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module
4.make編譯檔案 make install 下載編譯檔案
mkdir /var/temp/nginx -p
make
make install
5.檢視程序號關於nginx:
ps -ef|grep nginx
殺死程序號
kill -quiit PID
kill -term PID
pkill -9 nginx 強制停止
6.繫結配置檔案(這一步很重要):
./nginx -c /usr/local/nginx/conf/nginx.conf
7.重啟nginx ./nginx -s reload
開啟nginx ./nginx
也可用sudo /etc/init.d/nginx start 但是這裡的配置檔案不是我們修改的配置檔案
8.端口占用:
fuser -k 80/tcp
9.修改許可權
chmod 755 filename
10.nginx 配置埠和根目錄