configure more than one domain on linux

I Want to know what I have to configure to enable more than one domain on my Ubuntu server.
Ex.: domain1.com and domainxyz.com
Jose BredariolPMPAsked:
Who is Participating?
 
InsoftserviceCommented:
By default, apache comes with a default virtual host file called 000-default.conf. We will copy the 000-default.conf file contents to our new virtual host files.

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site2.com.conf

Make sure the virtual host files contains .conf extension at the end.

VIrtual container

<VirtualHost *:80>


        ServerAdmin webmaster@site1.com
        ServerName site1.com
        ServerAlias www.site1.com
        DocumentRoot /var/www/site1.com/public_html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Disable the default virtual host (000.default.conf), and enable new virtual hosts as shown below.

sudo a2dissite 000-default.conf
sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf

sudo service apache2 restart
0
 
GaryCommented:
Just add a virtual server block in httpd.conf for each domain.
Do you not have a control panel installed like WebMin or Cpanel - will make it easier.
0
 
Jan SpringerCommented:
In /etc/httpd/conf/httpd.conf, you will want to use the <VirtualHost> container to create your configuration.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
Jose BredariolPMPAuthor Commented:
I don´t have this file httpd.conf, I have to create ?
I have folders sites-enabled anda sites available
0
 
GaryCommented:
in sites-enabled, make a copy of the current domain .conf file
Edit it for the new domain, save, restart Apache.
0
 
Jose BredariolPMPAuthor Commented:
Thanks all
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.