douba2011 2013-12-31 10:56
浏览 69

Vagrant在文档根目录上失败

I am trying to set up a new Vagrant box. My bash script looks like this

#!/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? ---"

Although when I run vagrant up in the terminal I get this error

--- 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.

I have searched using the finder for /var/www and I am taken to the correct folder. The permissions for this folder are set at 755

Why would it fail in finding the document root?

  • 写回答

1条回答 默认 最新

  • donglan9517 2013-12-31 11:59
    关注

    I may be not right but I feel lines

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

    is giving you issue

    /vargrant/public rights should be also fine

    if I were to opt I could have not removed /var/www

    also symbolic links safe for me would be

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

    Atleast you will not find same error

    other points which perks me is why can't you set virtual host directory to /vagrant/public path in apache.conf file

    say append file with

     <VirtualHost *:80>
    DocumentRoot /vagrant/public
    ServerName somenameorip
    
    </VirtualHost>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM