0

The issue I'm having is that when I visit http://d7.subdomain.example.org from my host machine, it takes me to the default apache It Works page. I'm on a Mac host with a Ubuntu 12.04 Vagrant box with virtualbox provider.

I've checked sites-enabled/ and the site does appear there after running the sudo a2ensite d7.subdomain.example.org command. If I go to http://d7.subdomain.example.org/drupal/site-docroot it takes me to the right place. It seems like it's ignoring my vhost all together.

My Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.box = "precise32"

  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
  config.vm.define "drupal" do |node|
    node.vm.hostname = "d7.subdomain.example.org"
    node.vm.network :private_network, ip: "172.22.22.26"
    node.hostmanager.aliases = [ "www.d7.subdomain.example.org" ]
  end
  config.vm.provision :hostmanager

  config.vm.synced_folder "./drupal", "/var/www/html/drupal/", type: "nfs"

  config.vm.provider "virtualbox" do |vm|
    vm.customize ["modifyvm", :id, "--memory", "2048"]
    vm.customize ["modifyvm", :id, "--cpus", "1"]
    vm.customize ["modifyvm", :id, "--cpuexecutioncap", "85"]
  end

  config.vm.provision "shell" do |script|
    script.path = "provisioner.sh"
  end


end

My provisioning script:

#! /bin/bash
sudo apt-get update -y
sudo apt-get install apache2 -y
sudo apt-get install debconf-utils -y
debconf-set-selections <<< "mysql-server mysql-server/root_password password rootpw"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password rootpw"
sudo apt-get install mysql-server -y
mysql -uroot -prootpw -e "CREATE DATABASE mydbford7;
USE mydbford7;
SOURCE /var/www/html/drupal/setup/dump.sql;
CREATE USER 'vagrant'@'localhost' IDENTIFIED BY 'vagrant';
GRANT ALL PRIVILEGES ON mydbford7.* TO 'vagrant'@'localhost' IDENTIFIED BY 'vagrant';
FLUSH PRIVILEGES;"
sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf
sudo service mysql restart
sudo apt-get install python-software-properties build-essential -y
sudo add-apt-repository ppa:ondrej/php5 -y
sudo apt-get install php5-common php5-dev libapache2-mod-php5 php5-cli php5-fpm -y
sudo apt-get install curl php5-curl php5-gd php5-mcrypt php5-mysql -y
a2enmod rewrite
sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
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
cp /var/www/html/drupal/setup/myd7_vhost /etc/apache2/sites-available/d7.subdomain.example.org.conf
sudo a2ensite d7.subdomain.example.org
sudo service apache2 restart
sudo service apache2 reload

Virtual host file:

<VirtualHost *:80>
        ServerName d7.subdomain.example.org
        ServerAdmin me@example.com

        DocumentRoot "/var/www/html/drupal/site-docroot"

        <Directory "/var/www/html/drupal/site-docroot/">
                Options All
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog "/var/log/apache2/error_log"
        TransferLog "/var/log/apache2/access_log"
</VirtualHost>
CR47
  • 103
  • 1
  • 1
  • 5

2 Answers2

3

Perhaps you have the default-000.conf file messing up your virtualhost configuration.

Run apache2ctl -S to have the full list of virtualhost enabled on your server.

pixeline
  • 658
  • 3
  • 13
  • 29
0

You can create virtual host config file for your project by running the bellow commands:

vhost="<VirtualHost *:80>
     ServerName site_name.local
     DocumentRoot /path/to/project

     <Directory /path/to/project>
          Order allow,deny
          Allow from all
          Require all granted
          AllowOverride All
    </Directory>

     ErrorLog ${APACHE_LOG_DIR}/sitename_error.log
     CustomLog ${APACHE_LOG_DIR}/sitename_access.log combined
</VirtualHost>"

echo "$vhost" | sudo tee /etc/apache2/sites-available/site_name.local.conf

sudo a2ensite site_name.local.conf

service apache2 restart

Then edit your host file

sudo nano /etc/hosts

and add your localhost ip with site name like:

127.0.0.1       your_site_name

Now you can test your project in browser by typing your site url: http://your_site_name/

That's it :)

Imran Khan
  • 101
  • 3