centos nginx設定多站點

2021-06-28 06:45:01 字數 1499 閱讀 4647

配置虛擬站點

這裡以配置2個站點(2個網域名稱)為例,n 個站點可以相應增加調整,假設:

網域名稱1 example1.com 放在 /www/example1

網域名稱2 example2.com 放在 /www/example2

配置 nginx virtual hosting 的基本思路和步驟如下:

把2個站點 example1.com, example2.com 放到 nginx 可以訪問的目錄 /www/

給每個站點分別建立乙個 nginx 配置檔案 example1.com.conf,example2.com.conf, 並把配置檔案放到 /etc/nginx/vhosts/

然後在 /etc/nginx.conf 裡面加一句 include 把步驟2建立的配置檔案全部包含進來(用 * 號)

重啟 nginx

具體過程

下面是具體的配置過程:

1、在 /etc/nginx 下建立 vhosts 目錄

mkdir /etc/nginx/vhosts

2、在 /etc/nginx/vhosts/ 裡建立乙個名字為 example1.com.conf 的檔案,把以下內容拷進去

server

error_page   500 502 503 504  /50x.html;

location = /50x.html

# pass the php scripts to fastcgi server listening on 127.0.0.1:9000

location ~ /.php$

location ~ //.ht

}3、在 /etc/nginx/vhosts/ 裡建立乙個名字為 example2.com.conf 的檔案,把以下內容拷進去

server

error_page   500 502 503 504  /50x.html;

location = /50x.html

# pass the php scripts to fastcgi server listening on 127.0.0.1:9000

location ~ /.php$

location ~ //.ht

}4、開啟 /etc/nginix.conf 檔案,在相應位置加入 include 把以上2個檔案包含進來

}# 包含所有的虛擬主機的配置檔案

include /usr/local/etc/nginx/vhosts/*;

}5、重啟 nginx

/etc/init.d/nginx restart

設定源站保護

已接入web應用防火牆進行防護後,您可以設定源站伺服器的訪問控制策略,只放行web應用防火牆回源ip段的入方向流量,防止黑客獲取您的源站ip後繞過web應用防火牆直接攻擊源站。本文介紹了源站伺服器部署在雲伺服器ecs 負載均衡slb時,如何設定對應的安全組規則和白名單策略。已接入web應用防火牆進行...

php open basedir設定防止跨站

通過在 掛馬,進入到php的目錄,如果php開啟了scandir方法的話,可以直接通過目錄一級一級的像上面進入,此操作會造成很大的風險。下面給出php的木馬檔案 p 獲得外掛程式 formfooter end eval elseif act editfile end editfile elseif ...

Apache 多網域名稱多站點設定

httpd.conf 檔案 找到serveradmin 前面打上 不含雙引號 也就是把這段注釋掉.找到documentroot d program files apache2.2 htdocs 這個是你安裝apache的位置,自己應該曉得 把這段也打上 注釋掉.假如,虛擬空間的各個站點都在d盤的ww...