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

原文地址:https://www.cnblogs.com/makeup/p/5433837.html