配置nginx的方法:首先要打開(kāi)“/etc/nginx/conf.d/”文件夾;然后創(chuàng)建配置文件;接著在“/etc/nginx/nginx.conf”文件中修改配置項(xiàng);最后重新啟動(dòng)nginx即可。
Nginx是一款輕量級(jí)的Web 服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器
Nginx (engine x) 也是一個(gè)高性能的HTTP和反向代理服務(wù),也是一個(gè)IMAP/POP3/SMTP服務(wù)。Nginx是由伊戈?duì)枴べ愃饕驗(yàn)槎砹_斯訪問(wèn)量第二的Rambler.ru站點(diǎn)(俄文:Рамблер)開(kāi)發(fā)的 ? ?(推薦學(xué)習(xí):nginx教程)
前后端nginx配置
1.打開(kāi) /etc/nginx/conf.d/文件夾,創(chuàng)建配置文件xxx.conf,內(nèi)容如下:
server { listen 80; server_name **.106.2**.175; location / { root /public/app/dist; index index.php index.html index.htm; } location /sell { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080; proxy_redirect off; }}
在 /etc/nginx/nginx.conf文件中有一行就是把剛剛配置的引進(jìn)總的nginx配置中
... include /etc/nginx/conf.d/*.conf;...
3.配置完成后重新啟動(dòng)nginx
nginx -t # 查看nginx狀態(tài) nginx -s reload # 重新載入配置文件 nginx -s reopen # 重啟 Nginx nginx -s stop # 停止 Nginx
配置https
server { listen 443; server_name xx.name.com; ssl on; index index.html index.htm; ssl_certificate cert/215079423330181.cert; ssl_certificate_key cert/215079423330181.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /public/app/dist; index index.php index.html index.htm; } location /sell { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080; proxy_redirect off; } }
nginx.conf 默認(rèn)文件
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; gzip on; gzip_static on; gzip_min_length 1024; gzip_buffers 4 16k; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php application/vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml; gzip_vary off; gzip_disable "MSIE [1-6]\."; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } server { listen 443; server_name mp.hanxing.store; ssl on; index index.html index.htm; ssl_certificate cert/cert_mp.hanxing.store.crt; ssl_certificate_key cert/cert_mp.hanxing.store.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root /public/sell/app/dist; index index.php index.html index.htm; } location /sell { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8080; proxy_redirect off; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
以上是nginx怎么配置的詳細(xì)內(nèi)容。更多信息請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

熱AI工具

Undress AI Tool
免費(fèi)脫衣服圖片

Undresser.AI Undress
人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover
用于從照片中去除衣服的在線人工智能工具。

Clothoff.io
AI脫衣機(jī)

Video Face Swap
使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱門(mén)文章

熱工具

記事本++7.3.1
好用且免費(fèi)的代碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
功能強(qiáng)大的PHP集成開(kāi)發(fā)環(huán)境

Dreamweaver CS6
視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版
神級(jí)代碼編輯軟件(SublimeText3)

熱門(mén)話題

如何在 Windows 中配置 Nginx?安裝 Nginx 并創(chuàng)建虛擬主機(jī)配置。修改主配置文件并包含虛擬主機(jī)配置。啟動(dòng)或重新加載 Nginx。測(cè)試配置并查看網(wǎng)站。選擇性啟用 SSL 并配置 SSL 證書(shū)。選擇性設(shè)置防火墻允許 80 和 443 端口流量。

Docker 容器啟動(dòng)步驟:拉取容器鏡像:運(yùn)行 "docker pull [鏡像名稱]"。創(chuàng)建容器:使用 "docker create [選項(xiàng)] [鏡像名稱] [命令和參數(shù)]"。啟動(dòng)容器:執(zhí)行 "docker start [容器名稱或 ID]"。檢查容器狀態(tài):通過(guò) "docker ps" 驗(yàn)證容器是否正在運(yùn)行。

可以通過(guò)以下步驟查詢 Docker 容器名稱:列出所有容器(docker ps)。篩選容器列表(使用 grep 命令)。獲取容器名稱(位于 "NAMES" 列中)。

確認(rèn) Nginx 是否啟動(dòng)的方法:1. 使用命令行:systemctl status nginx(Linux/Unix)、netstat -ano | findstr 80(Windows);2. 檢查端口 80 是否開(kāi)放;3. 查看系統(tǒng)日志中 Nginx 啟動(dòng)消息;4. 使用第三方工具,如 Nagios、Zabbix、Icinga。

在 Docker 中創(chuàng)建容器: 1. 拉取鏡像: docker pull [鏡像名] 2. 創(chuàng)建容器: docker run [選項(xiàng)] [鏡像名] [命令] 3. 啟動(dòng)容器: docker start [容器名]

問(wèn)題:如何啟動(dòng) Nginx?答案:安裝 Nginx啟動(dòng) Nginx驗(yàn)證 Nginx 是否已啟動(dòng)探索其他啟動(dòng)選項(xiàng)自動(dòng)啟動(dòng) Nginx

NGINX和Apache各有優(yōu)劣,適合不同場(chǎng)景。1.NGINX適合高并發(fā)和低資源消耗場(chǎng)景。2.Apache適合需要復(fù)雜配置和豐富模塊的場(chǎng)景。通過(guò)比較它們的核心特性、性能差異和最佳實(shí)踐,可以幫助你選擇最適合需求的服務(wù)器軟件。

提升CentOS系統(tǒng)下PhpStorm性能的實(shí)用技巧本文提供多種方法,幫助您優(yōu)化CentOS系統(tǒng)中PhpStorm的性能,從而提高開(kāi)發(fā)效率。在實(shí)施任何優(yōu)化措施前,請(qǐng)務(wù)必備份重要數(shù)據(jù)并在測(cè)試環(huán)境中驗(yàn)證效果。一、系統(tǒng)級(jí)優(yōu)化精簡(jiǎn)系統(tǒng)服務(wù):禁用不必要的系統(tǒng)服務(wù)和守護(hù)進(jìn)程,減少系統(tǒng)資源占用。無(wú)界面模式:如果不需要圖形界面,切換到無(wú)界面模式可顯著節(jié)省資源。卸載冗余軟件:移除不再使用的軟件包和服務(wù),釋放系統(tǒng)資源。二、PHP配置優(yōu)化啟用OPcache:安裝并配置OPcache擴(kuò)展,顯
