這里就不介紹同一端口和同一nginx.conf,有需要的童鞋自行百度。
這里介紹不同項目的不同配置。
服務(wù)器中已經(jīng)部署了其他項目,這里做一個簡單的頁面做測試:
1、新建目錄:
/root/nginx/8571/
/root/nginx/8571/html/
/root/nginx/8571/log/
2、將文件:/usr/sbin/nginx 拷貝至 /root/nginx/8571/
3、新建index.html:/root/nginx/8571/html/index.html
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>12</title>
</head>
<body>
<div id="app">
cesi
</div>
</body>
</html>
4、新建配置文件:/root/nginx/8571/nginx.conf

微信圖片_20220623180125.png
user root;
worker_processes auto;
pid /root/nginx/8571/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
# ssl_protocols TLSV1 TLSv1.1 TLSv1.2; # Dropping SsLv3,ref: POODLE
# ssl_preter serverciphers on;
#access_log /root/nginx/8571/log/access.log;
#error_log root/nginx/8571/error.log;
gzip on;
gzip_disable "msie6";
server {
listen 8571;
location /{
root /root/nginx/8571/html/;
index index.html index.htm;
}
}
}
5、啟動 nginx
./nginx -c /root/nginx/8571/nginx.conf
注意:
若 nginx.conf 配置 location 后,重啟 nginx 再訪問,如果訪問提示:Nginx 403 Forbidden,則需要在 nginx.conf 頭部加入一行:
user root;
查看nginx端口使用情況:netstat -apn
啟動成功后輸入ip和端口8571訪問:

微信圖片_20220623180438.png
關(guān)注小編不定時更新更多精彩內(nèi)容