Skip to content
FullStackDost Logo
  • All Courses
  • Blogs
  • Login
  • Register
  • All Courses
  • Blogs
  • Login
  • Register
  • Home
  • All Courses
  • Full Stack Development
  • LAMP Tutorials

LAMP Tutorials

Curriculum

  • 1 Section
  • 5 Lessons
  • 2 Weeks
Expand all sectionsCollapse all sections
  • LAMP Tutorials
    The LAMP stack is a popular open-source web development platform that consists of four key components: Linux, Apache, MySQL, and PHP.
    5
    • 1.1
      LAMP Stack
    • 1.2
      Apache installation on Linux
    • 1.3
      Apache virtual host configuration on Linux
    • 1.4
      MySQL installation on Linux
    • 1.5
      PHP installation on Linux

Apache virtual host configuration on Linux

Configuring virtual hosts in Apache on Linux involves setting up multiple websites on a single Apache web server, each with its own domain name and separate configuration. Here’s a basic guide to configuring virtual hosts in Apache on Linux:

  1. Navigate to Apache Configuration Directory: First, navigate to the Apache configuration directory. The location may vary depending on your Linux distribution, but it’s typically /etc/apache2/sites-available/ or /etc/httpd/conf.d/.
  2. Create a New Configuration File: Create a new configuration file for each virtual host you want to set up. Use a descriptive filename ending with .conf. For example, to create a virtual host configuration for example.com, you can use example.com.conf.
    • sudo nano /etc/apache2/sites-available/example.com.conf
  3. Configure the Virtual Host: Inside the configuration file, specify the virtual host configuration using the following format:
    • <VirtualHost *:80>
      ServerAdmin webmaster@example.com
      ServerName example.com
      DocumentRoot /var/www/example.com/public_html
      ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
      CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
      </VirtualHost>
    • Replace example.com with your domain name, /var/www/example.com/public_html with the path to your website files, and webmaster@example.com with your email address.
  4. Enable the Virtual Host: Once you’ve configured the virtual host, you need to enable it by creating a symbolic link to the sites-enabled directory. Use the a2ensite command, followed by the name of your configuration file (without the .conf extension).
    • sudo a2ensite example.com
  5. Restart Apache: After enabling the virtual host, restart Apache to apply the changes.
    • sudo systemctl restart apache2
  6. Repeat for Additional Virtual Hosts: Repeat the above steps for each additional virtual host you want to configure on the same Apache server.
  7. DNS Configuration: Finally, make sure that the DNS records for your domain names point to the IP address of your Apache server. You can do this by adding A records or CNAME records in your DNS provider’s control panel.

Once configured, Apache will serve each website from its respective document root directory, based on the domain name requested by the client. This allows you to host multiple websites on a single Apache server, each with its own configuration and content.

Apache installation on Linux
Prev
MySQL installation on Linux
Next

Copyright © 2025 FullStackDost. All Rights Reserved.

Theme by ILOVEWP