Guide to creating staging/development subdomains for Magento on Nexcess

Basic guide - Creating a Magento staging domain with Nexcess Hosting

  • 1.1-2.9 Use the Nexcess Portal to create a new subdomain and database+user
  • 3. Copy the desired website files (including the hidden .htaccess file) to the new subdomains folder
  • 4.1-4.6 Create dump of desired websites database using mysqldump with the credentials in the "app/etc/local.xml" file
  • 4.7 Import the new database dump into the new subdomains database
  • 5.1 Using some SQL client (Nexcess hosted PhpMyAdmin, bash mysql prompt, or some other) on the new subdomains database edit the column "value" for each row in the "core_config_data" table with path values of "web/unsecure/base_url" and "web/secure/base_url" to reflect the new subdomain + domain name
  • 5.2.3 Edit the new subdomains .htaccess file and uncomment "RewriteBase /"
  • 5.2.4 Edit the new subdomains local settings file (app/etc/local.xml) and enter the new subdomains database credentials.

 

Full Guide

  1. Create a subdomain
    1. Log into nexcess portal
    2. Click "Add a Subdomain" in the right hand box labeled "Common Tasks"
    3. Enter the desired subdomain (e.g. www, dev, staging, etc) in the box and click OK.
    4. The new subdomain will be created as a folder in your websites root directory (e.g. /data_www/SubDomainName/)
  2. Create the database
    1. Log into the Nexcess portal
    2. Expand "Hosting Features" in the left hand navigation tree
    3. Expand "MySQL" in the left hand navigation tree
    4. Click Databases
    5. Enter new database name (will be prefixed with the account username followed by an underscore automatically, e.g. exampl1_SubDomainDatabaseName)
    6. Check the "Create User" box and choose a username (This followed the same prepend rule as the database name) Note: the username field has a shorter character limit than the database name field. If you copy and paste make sure you double check it.
    7. Choose a password or click Generate, record database name, username, and password in safe location
    8. Change "When Connecting From:" textbox from "%" to "localhost" (if the database is on the same machine.)
    9. Click "Add"
  3. Create copy of website files
    1. Copy Files from the website root directory (e.g. /data_www/) to the subdomain directory (e.g. /data_www/SubDomainName/)
      Note: This can easily be done with either WinSCP or SSH. Using WinSCP may prompt you to create a second session and may be slow. Using SSH will be much faster
      1. Using SSH
        1. Log into the website with PuTTY
        2. change directories to your subdomains root folder (cd example.com/html/SubDomainName/)
        3. Copy all files from the parent directory/your websites root directory to this folder (cp -R ../* ../.htaccess .)
      2. Using WinSCP
        1. Log into the website with WinSCP
        2. Navigate to your websites root directory (e.g. "~/example.com/html/")
        3. Select all files except for the subdomains folder
        4. Right click and select "Duplicate..."
        5. Change the target remote path from the current location (e.g. "/chroot/home/exampl1/example.com/html/*.*") to the location of your subdomain(e.g. "/chroot/home/exampl1/example.com/html/SubDomainName/*.*")
        6. Click OK to start the copy.
        7. You may recieve a confirmation asking to create a second session, if so, click OK and re-enter the servers credentials to start the copy.
  4. Create working copy of the website to be copied tables in the new subdomains database
    1. Log into the website with PuTTY.
    2. Change directories to your websites local settings file (websiteRoot/app/etc)
    3. Edit "local.xml" (vi local.xml) and make note of the default database connection information (contained in xml username, password, and dbname tags)
    4. Close editor (escape, :, q, !, enter)
    5. Create a copy of the working database (using the above noted credentials) and export it to a sql file (e.g. mysqldump -u {USER_NAME} --password {Previously_Noted_DATABASE_NAME} > WorkingDatabaseBackup.sql)
    6. You will be prompted to enter the password for the primary websites database (found in the step above)
    7. After the database dump is complete, Using the new subdomains database and user credentials (like exampl1_SubDomainDatabaseName) import the database information into the new subdomains database (e.g. mysql -u {USER_NAME} --password {DATABASE_NAME} < WorkingDatabaseBackup.sql)
  5. Final Setup
    1. Database
      1. Log into the Nexcess portal
      2. Expand Hosting Features/MySQL on the left hand navigation menu
      3. Click PhpMyAdmin to open the SQL manager.
      4. Click the newly created subdomain in the left hand navigation pane (e.g. _SubDomainDatabaseName)
      5. Scroll to and click the "core_config_data" table in the left navigation pane.
      6. In the right pane click the "Search" tab along the top of the window.
      7. Change the "path" "Operator" to "IN (...)"
      8. Enter "web/secure/base_url, web/unsecure/base_url" as the "path" "value" and click "GO"
      9. Scroll down and double click the value (e.g. http://www.example.com) for each path and change it to the correct path for the subdomain (e.g. http://subdomain.example.com)
      10. Click out of the value field (any blank space) to save the changes
    2. Website
      1. Log into the website with PuTTY.
      2. change directories to your subdomains root folder (cd example.com/html/SubDomainName/)
      3. Tweak URL rewriting to work with a subfolder+domain
        1. Edit the ".htaccess" file (vi .htaccess)
        2. Enter editing mode by pressing "i" on the keyboard
        3. Find the line "#RewriteBase /" and change it to "RewriteBase /" using the keyboard arrows to navigate the file.
        4. Press the escape key to exit editing mode, colon (:) to open the menu, and wq followed by enter to save and exit the file.
      4. Enter the new subdomains database credentials
        1. Edit the subdomains local.xml config file (e.g. vi app/etc/local.xml)
        2. Enter editing mode by pressing "i" on the keyboard
        3. Using the keyboard to navigate, change the username, password, and dbname to match the newly created subdomains database
        4. information.
        5. Press the escape key to exit editing mode, colon (:) to open the menu, and wq followed by enter to save and exit the file.

 

Add Feedback