donglu4633 2016-06-03 06:46
浏览 239
已采纳

apache2.conf和httpd.conf

After reading ubuntu AMP community and Apache 2.4 configuration.

I was wondering if there is a way to imitate the same behavior of the http docs used in XAMPP or bitnami stacks but using the default LAMP. Which uses apache 2.4

In XAMP you would assign an extra number to your httpd-vhost.conf like this:

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>

Then Edit your httpd.conf files like:

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

and uncomment this line:

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

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

//...Some code...

My question is:

Is there is a way to configure Apache 2.4 just by dropping all my vhost's in one single file, without having to go through the process of configuring etc/apache2/sites-available and then adding names to etc/hosts?

Then completing the process by including some things like above just like Bitnami or Xamp stacks will do so your localhost will be able to serve not only static html files but an entire application's folder.

展开全部

  • 写回答

1条回答 默认 最新

  • duanjing4667 2016-06-03 07:22
    关注

    What works is the following in (for example) your 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>
    

    This way all you have to do is add the site to the conf file, add the host to your hosts file, and reload apache2 service. Hope that is what you were looking for.

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 Mysql 一张表同时多人查询和插入怎么防止死锁
  • ¥20 centos6.7 安装libevent库.总是报错,如何解决?
  • ¥15 电脑买回,学校的有线网络总掉。
  • ¥20 关于普洛菲斯触摸屏与AB连接地址问题
  • ¥15 vue但是页面显示的数据为空为什么呀,明明在钩子函数中已经成功赋值(相关搜索:输出数据)
  • ¥15 syri可视化不显示插入缺失
  • ¥30 运行软件卡死查看系统日志分析不出来
  • ¥15 C语言代码改正特征选择算法设计,贝叶斯决策,,设计分类器,远程操作代码修正一下
  • ¥15 String 类valuve指向的问题
  • ¥15 在ros2的iron版本进行编译时遇到如下问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部