Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php DocumentRoot始终默认为/var/www/html,无法更改_Php_Apache_Vagrant_Document Root_Puphpet - Fatal编程技术网

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

Php DocumentRoot始终默认为/var/www/html,无法更改,php,apache,vagrant,document-root,puphpet,Php,Apache,Vagrant,Document Root,Puphpet,我已经使用PuPHPet(Vagrant Puppet PHP)设置了一个虚拟主机。显然,PuPHPet使用此配置为我创建了一个默认站点10-default\u vhost\u 80.conf <VirtualHost *:80> ServerName default ## Vhost docroot DocumentRoot "/var/www/html" ## Directories, there should at least be a decla

我已经使用PuPHPet(Vagrant Puppet PHP)设置了一个虚拟主机。显然,PuPHPet使用此配置为我创建了一个默认站点
10-default\u vhost\u 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>
<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>
 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/*"
默认配置为
apache2.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>
<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>
 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/*"
ServerName“local.puphpet”
ServerRoot“/etc/apache2”
PidFile${APACHE_PID_文件}
超时120
拒之门外
MaxKeepAliveRequests 100
暂停15分钟
用户www数据
组www数据
AccessFileName.htaccess
要求全部拒绝
选项如下符号链接
不允许超限
主机名查询
ErrorLog“/var/log/apache2/error.log”
日志级别警告
启用发送文件关闭
#听80
包括“/etc/apache2/mods enabled/*.load”
包括“/etc/apache2/mods enabled/*.conf”
包括“/etc/apache2/ports.conf”
日志格式“%h%l%u%t\%r\”%>s%b\“%%{Referer}i\\\“%%{User Agent}i\\”组合
日志格式“%h%l%u%t\%r\”%>s%b”通用
日志格式“%{Referer}i->%U”Referer
日志格式“%{User agent}i”代理
IncludeOptional“/etc/apache2/conf.d/*.conf”
IncludeOptional“/etc/apache2/sites enabled/*”

我已经禁用了
10-default\u vhost\u 80
并重新加载了apache,但是我的DocumentRoot仍然指向
/var/www/html/
我是否遗漏了什么?

因此我所做的是将
/var/www/html
变成一个符号链接并指向
/var/www/web
。这同时解决了我的问题

更新
我使用上面的解决方案发现了另一个问题,它影响了我的
xdebug
配置,进程无法在
/var/www/web
中找到文件,因为它正在符号链接
/var/www/html
中查找文件。所以 另一个解决方法是修改
10-default_vhost_80.conf
文件,手动将
/var/www/html
更改为
/var/www/web
,然后重新启动服务器。到目前为止还不错

更新2
因此,正确的解决方法是,您需要确保
目录块
已填充到
puphpet
配置程序中,它将生成您在下面的
yaml
文件中看到的
目录
部分。我认为这是因为对Apache2.4进行了更新,所以需要这样做

所以我最终得到了这个
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

另外,如果您看到您的
PHP
文件没有进行解析,请确保包含
文件\u match
部分。它不是由
puphpet
配置程序自动添加的,因此您需要通过硬代码将其添加进去。

我将docroot路径和目录路径更改为/var/www/www,如下所示。这仍然会创建html文件夹,但会从我想要的www文件夹提供服务

vhosts:
    av_dpp1xawpupht:
        servername: mysite.local
        serveraliases:
            - www.mysite.local
        docroot: /var/www/www
        port: '80'
        setenv:
            - 'APPLICATION_ENV development'
        custom_fragment: ''
        ssl: '0'
        ssl_cert: ''
        ssl_key: ''
        ssl_chain: ''
        ssl_certs_dir: ''
        ssl_protocol: ''
        ssl_cipher: ''
        directories:
            avd_rtgzo3tlwbux:
                path: /var/www/www
                options:
                    - Indexes
                    - FollowSymlinks
                    - MultiViews
                allow_override:
                    - All
                require:
                    - 'all granted'
                custom_fragment: ''
                files_match:
                    avdfm_q9dzltiv10d5:
                        path: \.php$
                        sethandler: 'proxy:fcgi://127.0.0.1:9000'
                        custom_fragment: ''
                        provider: filesmatch
                provider: directory

我也有这个问题

对我来说,这是由于我的
puphpet/config.yaml
文件中的
servername
属性与我的
hosts
文件中列出的域不匹配造成的

我确保了在我的
puphpet/config.yaml
文件中指定的ip地址和域:

vm:
    network:
        private_network: 192.168.56.199
                  .
                  .
                  .

vhosts:
    av_9kfiq4m95oac:
        servername: mysite.dev
        serveraliases:
            - www.mysite.dev
192.168.56.199 mysite.dev www.mysite.dev
匹配我在我的
主机
文件中指定的内容:

vm:
    network:
        private_network: 192.168.56.199
                  .
                  .
                  .

vhosts:
    av_9kfiq4m95oac:
        servername: mysite.dev
        serveraliases:
            - www.mysite.dev
192.168.56.199 mysite.dev www.mysite.dev

哦,在对
puphpet/config.yaml
文件进行更改后,别忘了运行
vagrant provision
(这几次让我抓狂了).

我也这样做了,但使用了
/var/www/web
,但仍然是Puphpet创建了
10-default\u vhost\u 80
配置,它指向
/var/www/html
我认为这就是它指向
html
目录的原因。