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.