Vagrant在文档根目录上失败

时间:2013-12-31 10:56:54

标签: php bash vagrant

我正在尝试设置一个新的Vagrant框。我的bash脚本看起来像这样

#!/usr/bin/env bash

echo "--- Good morning, master. Let's get to work. Installing now. ---"

echo "--- Updating packages list ---"
sudo apt-get update

echo "--- MySQL time ---"
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'

echo "--- Installing base packages ---"
sudo apt-get install -y vim curl python-software-properties

echo "--- Updating packages list ---"
sudo apt-get update

echo "--- We want the bleeding edge of PHP, right master? ---"
sudo add-apt-repository -y ppa:ondrej/php5

echo "--- Updating packages list ---"
sudo apt-get update

echo "--- Installing PHP-specific packages ---"
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt mysql-server-5.5 php5-mysql git-core

echo "--- Installing and configuring Xdebug ---"
sudo apt-get install -y php5-xdebug

cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
xdebug.scream=1
xdebug.cli_color=1
xdebug.show_local_vars=1
EOF

echo "--- Enabling mod-rewrite ---"
sudo a2enmod rewrite

echo "--- Setting document root ---"
sudo rm -rf /var/www
sudo ln -fs /vagrant/public /var/www


echo "--- What developer codes without errors turned on? Not you, master. ---"
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini

sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf

echo "--- Restarting Apache ---"
sudo service apache2 restart

echo "--- Composer is the future. But you knew that, did you master? Nice job. ---"
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

echo "--- All set to go! Would you like to play a game? ---"

虽然当我在终端中运行vagrant up时出现此错误

--- What developer codes without errors turned on? Not you, master. ---
--- Restarting Apache ---
* Restarting web server apache2
AH00112: Warning: DocumentRoot [/var/www] does not exist
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
...done.

我使用查找器搜索了/ var / www,我被带到了正确的文件夹。此文件夹的权限设置为755

为什么找不到文档根目录会失败?

1 个答案:

答案 0 :(得分:0)

我可能不对,但我觉得行

echo "--- Setting document root ---"
sudo rm -rf /var/www
sudo ln -fs /vagrant/public /var/www

给你发出问题

/vargrant/public权利也应该没有问题

如果我选择我可能没有删除/ var / www

对我来说安全的符号链接也是

sudo ln -fs  /var/www /vagrant/public

至少你不会发现同样的错误

其他让我烦恼的点是为什么你不能在apache.conf文件中将虚拟主机目录设置为/vagrant/public路径

说用

附加文件
 <VirtualHost *:80>
DocumentRoot /vagrant/public
ServerName somenameorip

</VirtualHost>