前言
之前已經(jīng)在多網(wǎng)站搭建中用多域名的方式實(shí)現(xiàn)了多網(wǎng)站的搭建,這次簡(jiǎn)單記錄下在沒(méi)有域名時(shí)鸵荠,使用多端口實(shí)現(xiàn)多站點(diǎn)搭建的辦法
環(huán)境
- Ubuntu 12.04 LTS
- PHP
- Apache2
- Mysql
需求
文件目錄
- Wordpress:site.com/public
- discuz: bbs/public
端口
- Wordpress: ip:8080
- discuz: ip:80
實(shí)現(xiàn)
配置文件在 /etc/apache2
ports.conf
NameVirtualHost *:80
Listen 80
Listen 8080
- NameVirtualHost:指定服務(wù)器IP地址(和可能的端口)來(lái)使主機(jī)接受請(qǐng)求
- * 表示任一服務(wù)器IP
- 開啟對(duì)8080端口的偵聽(tīng)
./sites-available/site.com.conf
wordpress 虛擬主機(jī)配置文件
<VirtualHost *:8080>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin email
ServerName blog#沒(méi)有域名,隨便填
ServerAlias blog#同上
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/user/public/site.com/public
# Log file locations
LogLevel warn
ErrorLog /home/user/public/site.com/log/error.log
CustomLog /home/user/public/site.com/log/access.log combined
</VirtualHost>
- DocumentRoot:wordpress存放目錄
- 以8080端口的請(qǐng)求使用此配置文件
./sites-available/bbs.conf
bbs 虛擬主機(jī)配置文件
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin email
ServerName bbs
ServerAlias bbs
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/user/public/bbs/public
# Log file locations
LogLevel warn
ErrorLog /home/user/public/bbs/log/error.log
CustomLog /home/user/public/bbs/log/access.log combined
</VirtualHost>
wordpress更改默認(rèn)端口
在wordpress的后臺(tái)中商佑,在General Settings里耕挨,將網(wǎng)站url加上端口8080
小tips
之前修改端口配置后,怎么都搞不定鹃彻,后檢查log文件郊闯,發(fā)現(xiàn)訪問(wèn)8080端口時(shí),確實(shí)訪問(wèn)到了wordpress目錄蛛株,只是后來(lái)跳轉(zhuǎn)到了discuz目錄团赁,所以確定是wordpress的默認(rèn)端口80導(dǎo)致的跳轉(zhuǎn)。
修改wordpress的默認(rèn)端口后谨履,多端口訪問(wèn)多站點(diǎn)功能成功實(shí)現(xiàn)