apache2.conf和httpd.conf

时间:2016-06-03 14:47:00

标签: php apache ubuntu

阅读ubuntu AMP communityApache 2.4 configuration

我想知道是否有办法模仿XAMPP或bitnami堆栈中使用的http文档的相同行为,但使用默认的LAMP。其中使用apache 2.4

在XAMP中,您可以为httpd-vhost.conf分配一个额外的号码,如下所示:

Listen *:9000 
<virtualhost *:9000>  
    ServerName localhost 
    DocumentRoot "~/xamp/apache2/htdocs/html/app-name/" 
</virtualhost> 

<Directory "~/xamp/apache2/htdocs/html/app-name/">  
    Options Indexes FollowSymLinks  
    AllowOverride all 
</Directory>

然后编辑您的httpd.conf文件,如:

//....Some code.....   */ 
<Directory>
    AllowOverride all
<Directory /> 
//...Some code...

并取消注释这一行:

//....Some code.....   */ 

# Virtual hosts
include conf/extra/httpd-vhosts.conf 

//...Some code...

我的问题是:

是否有办法配置Apache 2.4只需将所有vhost放在一个文件中,而无需完成配置etc/apache2/sites-available然后向etc/hosts添加名称的过程?

然后通过包含像Bitnami或Xamp堆栈之类的一些事情来完成这个过程将会这样做,你的localhost不仅可以提供静态html文件,还可以提供整个应用程序的文件夹。

1 个答案:

答案 0 :(得分:0)

在(例如)000-default.conf:

中有以下内容
<VirtualHost *:80>
    ServerName site1.vm

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site1/web/

    ErrorLog ${APACHE_LOG_DIR}/site1_error.log
    CustomLog ${APACHE_LOG_DIR}/site1_access.log combined

    <Directory /var/www/site1/web/>
        Options All
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName site2.vm

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/site2/web/

    ErrorLog ${APACHE_LOG_DIR}/site2_error.log
    CustomLog ${APACHE_LOG_DIR}/site2_access.log combined

    <Directory /var/www/site2/web/>
        Options All
        AllowOverride All
    </Directory>
</VirtualHost>

这样,您只需将站点添加到conf文件,将主机添加到hosts文件,然后重新加载apache2服务。希望这就是你要找的东西。