• Home
  • How to add multiple subdomains to an Apache server?

How to add multiple subdomains to an Apache server?

by:bcladmin September 11, 2024 0 Comments

mkdir -p /var/www/subdomain.domain.com/public_html

chown -R www-data:www-data /var/www/subdomain.domain.com/public_html

nano /etc/apache2/sites-available/subdomain.domain.com.conf

<VirtualHost *:80>

    ServerName subdomain.domain.com

    ServerAlias www.subdomain.domain.com

    ServerAdmin admin@domain.com

    DocumentRoot /var/www/subdomain.domain.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

a2ensite subdomain.domain.com.conf

service apache2 restart

Categories:

Leave Comment