我已经使用PuPHPet (Vagrant)建立了一个虚拟主机,显然PuPHPet用这个配置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>我创建了这个站点配置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>默认配置为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/*"我已经禁用了10-default_vhost_80并重新加载了apache,但是我的DocumentRoot仍然指向/var/www/html/,是不是遗漏了什么?
发布于 2015-05-20 15:07:08
所以我所做的就是把/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
因此,正确的解决方法是确保Directory Block被填充在puphpet配置器中,并生成您在下面的yaml文件中看到的directories部分。我认为这是由于对apache 2.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文件没有解析,请确保包含该files_match部分。它不是由puphpet配置器自动添加的,所以您需要通过硬代码将其添加进来。
发布于 2015-06-08 13:39:14
我将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发布于 2015-09-01 17:27:51
我也有这个问题。
对我来说,这是由于我的servername文件中的puphpet/config.yaml属性与puphpet/config.yaml文件中列出的域不匹配造成的。
我确保了我的puphpet/config.yaml文件中指定的ip地址和域:
vm:
network:
private_network: 192.168.56.199
.
.
.
vhosts:
av_9kfiq4m95oac:
servername: mysite.dev
serveraliases:
- www.mysite.dev匹配我在hosts文件中指定的内容:
192.168.56.199 mysite.dev www.mysite.dev哦,别忘了在修改了vagrant provision文件后运行puphpet/config.yaml (这让我吃了几次)。
https://stackoverflow.com/questions/30352753
复制相似问题