duanlun4411 2015-05-20 14:33
浏览 1196
已采纳

DocumentRoot始终默认为/ var / www / html,无法更改它

I've set up a Virtual host using PuPHPet (Vagrant-Puppet-PHP) Apparently PuPHPet creates a default site for me with this configuration 10-default_vhost_80.conf

 <VirtualHost *:80>
   ServerName default

   ## Vhost docroot
   DocumentRoot "/var/www/html"

   ## Directories, there should at least be a declaration for /var/www/html

   <Directory "/var/www/html">
     Options Indexes FollowSymlinks MultiViews
     AllowOverride All
     Require all granted

     <FilesMatch "\.php$">
       Require all granted
       SetHandler proxy:fcgi://127.0.0.1:9000
     </FilesMatch>

   </Directory>

   ## Logging
   ErrorLog "/var/log/apache2/default_vhost_80_error.log"
   ServerSignature Off
   CustomLog "/var/log/apache2/default_vhost_80_access.log" combined
 </VirtualHost>

And I've created this site config site_dev.conf

<VirtualHost *:80>
 ServerName site.dev

 ## Vhost docroot
 DocumentRoot "/var/www/web"

 ## Directories, there should at least be a declaration for /var/www/web

 <Directory "/var/www/web">
   Options Indexes FollowSymlinks MultiViews
   AllowOverride All
   Require all granted

   <FilesMatch "\.php$">
     Require all granted
     SetHandler proxy:fcgi://127.0.0.1:9000

   </FilesMatch>

 </Directory>

 ## Logging
 ErrorLog "/var/log/apache2/av_0rjxvm6sfxhm_error.log"
 ServerSignature Off
 CustomLog "/var/log/apache2/av_0rjxvm6sfxhm_access.log" combined

 ## Server aliases
 ServerAlias www.site.dev

 ## SetEnv/SetEnvIf for environment variables
 SetEnv APP_ENV dev
</VirtualHost>

The default config is apache2.conf

 ServerName "local.puphpet"
 ServerRoot "/etc/apache2"
 PidFile ${APACHE_PID_FILE}
 Timeout 120
 KeepAlive Off
 MaxKeepAliveRequests 100
 KeepAliveTimeout 15

 User www-data
 Group www-data

 AccessFileName .htaccess
 <FilesMatch "^\.ht">
     Require all denied
 </FilesMatch>

 <Directory />
   Options FollowSymLinks
   AllowOverride None
 </Directory>


 HostnameLookups Off
 ErrorLog "/var/log/apache2/error.log"
 LogLevel warn
 EnableSendfile Off

 #Listen 80


 Include "/etc/apache2/mods-enabled/*.load"
 Include "/etc/apache2/mods-enabled/*.conf"
 Include "/etc/apache2/ports.conf"

 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
 LogFormat "%h %l %u %t \"%r\" %>s %b" common
 LogFormat "%{Referer}i -> %U" referer
 LogFormat "%{User-agent}i" agent

 IncludeOptional "/etc/apache2/conf.d/*.conf"
 IncludeOptional "/etc/apache2/sites-enabled/*"

I've already disabled the 10-default_vhost_80 and reloaded apache however my DocumentRoot still points to /var/www/html/ am I missing something?

  • 写回答

3条回答 默认 最新

  • drux41001 2015-05-20 15:07
    关注

    So what I did was made the /var/www/html into a symbolic link and point to /var/www/web. This solved my problem for the mean time.

    UPDATE
    I found another problem using the solution above, it affects the xdebug configuration I have and the process cannot find the files in /var/www/web because it is looking for the files in the symbolic link /var/www/html. So another work around is modify the 10-default_vhost_80.conf file and change /var/www/html to /var/www/web manually and restart the server. So far so good.

    UPDATE 2
    So the proper fix is that you need to make sure that the Directory Block is filled up in the puphpet configurator and it would produce the directories section you see in the yaml file below. I think this is due to that update to apache 2.4 why this needs to be done.

    So I ended up with this config.yaml

        av_s4zfpb2muecx:
            servername: sandbox.dev
            serveraliases:
                - www.sandbox.dev
            docroot: /var/www/web
            port: '80'
            setenv:
                - 'APP_ENV dev'
            custom_fragment: ''
            ssl: '0'
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
            ssl_protocol: ''
            ssl_cipher: ''
            directories:
                avd_e84h116m6dg3:
                    path: /var/www/web
                    options:
                        - Indexes
                        - FollowSymlinks
                        - MultiViews
                    allow_override:
                        - All
                    require:
                        - 'all granted'
                    custom_fragment: ''
                    files_match:
                        avdfm_e84h116m6dg3:
                            path: \.php$
                            sethandler: 'proxy:fcgi://127.0.0.1:9000'
                            custom_fragment: ''
                            provider: filesmatch
                    provider: directory
    

    Also if you see that your PHP files aren't parsing make sure to include that files_match section. It's not added by the puphpet configurator automatically so you need to add that in via hard code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误