Over a million developers have joined DZone.

Running Multiple Domain Names on Apache Server

· DevOps Zone

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

Of course your PHP website domain name is a front-page online property. Your customers use it to access your site and it’s closely connected with your site’s brand. BTW  the words that make up a domain names are used by search engines to evaluate websites in search results.

It is a good idea to register multiple domain names that are similar to your website’s main domain name to protect your website’s online brand.  But it’s not the only advantage of using multiple domains, it gives you the ability to increase the usability, efficiency and scalability of your PHP application and of course to save your costs without having to set up separate instances.

So, let’s consider how to run multiple domains on Apache server to make your PHP application even more scalable and effective.

1. Log into your Jelastic account and click Create environment.

2. In the appeared window navigate to PHP tab, pick Apache server and specify the number of resources your application needs. After that enter your environment name and click Create.

PHP Environment with Apache Server

In some seconds your environment will appear on the Jelastic dashboard.

Multiple Domain Names Apache Environment

3. You need tohave the names in DNS, resolving to your IP address. So, buy domain names for your environment. It can be done in two ways: by adding CNAME record or by setting A Records. Read more here

4. Then click the Settings button for the environment you have created earlier and bind your domains. In this case we use the next URLs: mydomain.com and myseconddomain.com.

Binding Domain Name in Jelastic

Note: In this casewe put entries in our hosts file for local testing and this will work only from the machine with those hosts entries.

5. Now you can upload zip packages with your apps to the Deployment manager and deploy them to the environment you’ve created earlier.

PHP Application Deployment

Second PHP Application Deployment

6. Once your applications are successfully deployed click Config button for Apache server and navigate to the httpd.conf  file (conf directory) to specify your virtual host configurations:

Listen 80
<VirtualHost *:80>
    DocumentRoot /firstapp
    ServerName mydomain.com

<VirtualHost *:80>
    DocumentRoot /secondapp
    ServerName myseconddomain.com

Multiple Domain Names Apache Server Configuration

7. Save the changes and restart Apache in order to apply new settings.

Restart Apache Server

8. Now you can check the results to ensure the all works properly.

PHP Application in a Browser

Hope this stuff will be useful for you. Domain names are very crucial pieces of your online identity so don’t forget to protect them. With Jelastic it’s only few minutes. Enjoy!

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today


Published at DZone with permission of Marina Sprava, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}