Linux Apache 多站點配置
Centos 配置方式:
找到 /etc/httpd/conf/http.conf
添加監聽端口,eg: Listen 89
虛擬機配置,一個端口對應一個
<VirtualHost *:89> DocumentRoot "文件目錄" ServerName ****** ServerAlias <Directory "同上"> Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost>
保存退出。重啓apache
systemctl restart httpd.service
Ubuntu配置方式:
ubuntu中安裝的是apache2,沒有http.conf文件。你找到/etc/apache2/中,發現有一個apache.conf。
在apache2.conf中只是找到一些在Include行,並沒有相關設置。其實設置在/etc/apache2/sites-available/default中
找到/etc/apache2/sites-available/default,內容如下:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
裏面默認已添加一個80端口的,根據上面的配置,你添加另一個端口89
在找到/etc/apache2/ports.conf,添加一個監聽的端口。
Listen 89
保存退出,重啓Apache2即可。
service apache2 restart