linux apache添加多站點配置(Ubuntn和Centos)


 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>
View Code

 

里面默認已添加一個80端口的,根據上面的配置,你添加另一個端口89

在找到/etc/apache2/ports.conf,添加一個監聽的端口。

Listen 89

保存退出,重啟Apache2即可。

service apache2 restart

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM