nginx 監聽多個埠 80和81
首先找到nginx的配置檔案nginx.conf,開啟配置檔案後找到類似下面一段:
[[email protected] nginx]# cd /etc/nginx/conf.d/
然後把目錄下面的檔案都列出來:[[email protected] conf.d]# ll
預設的話,目錄下面有個default.conf檔案
開啟default.conf檔案後如下:
server { listen 80; server_name localhost; #charset koi8-r; access_log /var/log/nginx/access.log main; root /var/www/baidu; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php($|/) { try_files $uri =404; #rewrite ^/index.php/(.*)$ /$1 last; fastcgi_pass unix:/var/www/php-fpm.sock; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
如果把上面的配置作為本地配置一個百度網站的設定,那麼其訪問的埠為預設80埠,訪問地址就是:http://localhost/
如果我們想用81埠配置為本地的另外一個網站的訪問入口,應該怎麼配置呢?
首先你需要在conf.d目錄下建立一個以.conf結尾的檔案,比如:google.com.conf檔案,或者直接copy一個default.conf檔案也可以,具體配置如下:
server { listen 81; server_name localhost; #charset koi8-r; access_log /var/log/nginx/access.log main; root /var/www/google; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php($|/) { try_files $uri =404; #rewrite ^/index.php/(.*)$ /$1 last; fastcgi_pass unix:/var/www/php-fpm.sock; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
儲存後,重啟nginx伺服器
訪問:http://localhost:81看看是否成功吧。
注意:配置裡面的目錄檔案一定要存在,不然無法啟動nginx。
相關推薦
nginx 監聽多個埠 80和81
首先找到nginx的配置檔案nginx.conf,開啟配置檔案後找到類似下面一段: [[email protected] nginx]# cd /etc/nginx/conf.d/然後把目錄下面的檔案都列出來:[[email protected] con
Linux系統配置ssh監聽多個埠方法
1、為避免其他使用者惡意登陸裝置,一般會修改ssh登陸的埠修改方法如下: 在配置檔案 /etc/ssh/sshd_config 檔案中修改 Port 5022 #AddressFamily any#listenAddress 0.0.0.0:22 #ListenAdd
單執行緒實現同時監聽多個埠(windows平臺c++程式碼)
前言 多年前開發了一套網路庫,底層實現採用IOCP(完成埠)。該庫已在公司多個程式中應用;經過多次修改,長時間檢驗,已經非常穩定高效。 最近把以前的程式碼梳理了一下,又加進了一些新的思路。程式碼結構更加合理,效能也有所提升。打算將該庫一些的知識點寫出來,以供參考。 服務端要在多個埠監聽,這種場合並不多見。
apache配置監聽多個埠
在httpd.conf 中新增listen 比如listen 80 listen 8081 listen 8082等,把想要新增的埠號全部新增進來 把虛擬配置檔案載入進來
一臺電腦上同時監聽多個TCP埠有什麼副作用?
如題,伺服器和客戶端通訊,協議已經固化不能修改. 如果伺服器同時開啟1-20個,或者更多,每個監聽埠有1-1000個客戶端線上. 請問會產生什麼副作用嗎? 監聽多個埠沒有試過,現在也沒有條件進行模擬測試,請有經驗的人士告知.感激不盡!!
vue監聽多個變量的方法
control val param query als pre log 變量 tor vue當中有時需要監聽多個變量,方法如下,推薦方法一 一、把多個變量放在一個對象裏 data() { return { switchParam: {
Android開發20——單個監聽器監聽多個按鈕點選事件
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!  
react-redux實現監聽多個輸入框值,新增資料。一整套程式碼
1.mutation.js中 export const createSupportRecord = `mutation createSupportRecord($support: CreateSupportRecordInput!) { createSupportRecord(input:
vue computed監聽多個屬性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body&g
使用zabbix-java-gateway可以通過該閘道器來監聽多個JVM
我們知道監控主機和網路效能指標情況可以使用zabbix很好解決,分析起來也很方便,Zabbix主要功能: - 自動發現伺服器與網路裝置 - 分散式監視以及WEB集中管理功能 - 可以無agent監視 - 使用者安全認證和柔軟的授權方式 - 通過WEB介面設定或檢視監視結果
kafka broker監聽多個IP地址
場景 kafka broker所在伺服器有多個ip地址,需要進行監聽。 如server有A、B兩個ip地址,producer連線A傳送訊息,consumer連線B消費 配置 方法一
(轉載)一個簡短的epoll伺服器示例, 監聽5000個埠, 使用執行緒池[safedead.cublog.cn]
/*Linux 2.6 x86_64 only*/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <time.h>#include <unistd.h>#include
SqlServer服務是可以同時偵聽多個埠的
今天有個人問這個問題,我以前不知道,後來在SqlServer配置管理器裡的Tcp/Ip協議屬性窗口裡點幫助,裡面對這個問題寫的清清楚楚。茲記錄如下:TCP 埠 檢視或更改 SQL Server 偵聽的埠。預設情況下,資料庫引擎的預設例項偵聽埠 1433。 SQL Serv
監聽多個edittext內容 改變按鈕顏色
效果如下圖:當兩個edittext都輸入了內容才改變 "確定" 的顏色實現:其實就是在用到的時候 呼叫下面工具類的addAlledittext( )方法 把要監聽的edittext都傳進來 然
【android】:android實現監聽多個按鈕事件
直接擼程式碼: 我有四個按鈕,下面的程式碼演示瞭如何將多個按鈕用一個事件監聽 在onCreate函式裡面 Button button1 = (Button)findViewBy
epoll伺服器示例, 監聽5000個埠, 使用執行緒池
/*Linux 2.6 x86_64 only*/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <time.h>#include <unistd.h>#include
.Net TCP探索(一)——TCP服務端開發(同時監聽多個客戶端請求)
最近在園子裡看了大神寫的(面試官,不要再問我三次握手和四次揮手),忍不住寫段程式來測試一番。 在網上找了很多例子,大多隻實現了TCP點對點通訊,但實際應用中,一個伺服器埠往往要監聽多個客戶端發來的訊息。 測試工具下
Nginx監聽相同埠和IP通過域名分發到不同的應用伺服器
1、Nginx配置檔案如下: #user nobody; worker_processes 3; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log inf
oracle新增配置多個埠監聽
原來配置:listener.ora檔案如下: LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = DESKTOP-L9P3QTT)(PORT = 1521)) (ADDRESS = (PROTOCO
linux下啟動多個php,分別監聽不同的埠。
在工作中,我們可能會遇到,伺服器叢集的搭建。 這個時候,我們不可能,每一臺伺服器都是lnmp的環境,我們會把nmp分別放在不同的伺服器上,不同的伺服器負責不同的功能。比如我們下面要說的php 加入nginx和mysql已經在其他的伺服器上配置好了,這個時候我們就需要將php這另外一臺空閒的伺服器上配置好。