How do I setup a test and dev environment on one same EC2 Linux instance for a drupal site?

1

I am using EC2 linux instances to run a drupal 7 site.

I plan to have one server for the production site (drupalsite.com).

How can I set up an EC2 Linux instance to host both test and development environments with two different URL (dev.drupalsite.com and test.drupalsite.com)?

Izumi Bérat

Posted 2014-01-25T13:58:11.653

Reputation: 11

Answers

2

I'm going to make some assumptions here:

  • You are running Apache
  • You have already configured your domain so that both drupalsite.com and test.drupalsite.com have A records pointing to the IP address of your EC2 instance.

Now you've probably already configured your Apache web server to handle the VirtualHost drupalsite.com, e.g. in /etc/apache2/sites-available/default, or similar to the documentation on Drupal.com:

<VirtualHost *:80>
        ServerName drupalsite.com
        DocumentRoot /var/www/drupal-production/
        <Directory /var/www/drupal-production/>
                Options +FollowSymLinks Indexes
                AllowOverride All
                order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Now, you need to create a second VirtualHost that maps to a subdomain only:

<VirtualHost *:80>
        ServerName test.drupalsite.com
        DocumentRoot /var/www/drupal-test/
        <Directory /var/www/drupal-test/>
                Options +FollowSymLinks Indexes
                AllowOverride All
                order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Save this in your Apache configuration file and run /etc/init.d/apache2 reload – now any request to test.drupalsite.com will point to the other directory.

Naturally, you should configure your Drupal instance to use another database than the production server. It would also be good to secure the testing installation from access by unauthorized users and search engines. An .htpasswd lock comes to mind, or a restriction based on IP addres using the mod_access directives.

slhck

Posted 2014-01-25T13:58:11.653

Reputation: 182 472