SynteX
By:
SynteX

How to create a subdomain with apache on CentOS 7?

October 3, 2015 10.9k views
LEMP Apache PHP DNS CentOS

Hi,

I followed this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7

But my problem is that i don't have any idea how to set-up a subdomein my currently site is http://dev-talk.eu but i can't launch the admin panel i made cuz the admin panel needs a subdomain: admin.dev-talk.eu

But how can i create a subdomain?

1 Answer

If you follow this steps you have to edit YOUR_DOMAIN.conf file which is located /etc/httpd/sites-available/YOUR_DOMAIN.conf
TODO:

sudo nano /etc/httpd/sites-available/YOUR_DOMAIN.conf

add this codes end of the file:

<VirtualHost *:80>
    ServerName SUB_DOMAIN.YOUR_DOMAIN
    ServerAlias YOUR_DOMAIN
    DocumentRoot /YOUR/SUB/DOMAIN/PATH
    ErrorLog /YOUR/ERROR/LOG/PATH
    CustomLog /YOUR/REQUESTED/LOG/PATH combined
</VirtualHost>

Restart apache:

sudo apachectl restart
The Apache web server is extremely powerful and flexible, which is why it's the most popular way of serving web content. Apache can host multiple domains or interfaces on one server by splitting sites into separate virtual hosts. In this guide, we will walk you through how to set up Apache virtual hosts on a CentOS 7 VPS.
Have another answer? Share your knowledge.