Dino Geek, try to help you

How to manage multiple websites on an Apache server?


Managing multiple websites on an Apache server can be achieved by configuring virtual hosts. Here are the steps:

1. Enable Virtual Hosts: The first step is to make sure that you’ve enabled virtual hosting in Apache. Open the main Apache configuration file, typically named `httpd.conf` and uncomment the line that includes the virtual hosts file; it should look like this: `Include etc/extra/httpd-vhosts.conf`.

1. Set Up Domain Folder: For each new domain or subdomain you want to add, create a new directory in the root folder of Apache (usually named `htdocs`).

1. Create a Virtual Host File for Each Site: Open the `httpd-vhosts.conf` file (located by default in `etc/extra/`). Remove the default content and add a block of content for each of your sites, with information similar to the following example.

```
ServerAdmin webmaster@localhost DocumentRoot “/usr/local/apache/htdocs/mywebsite“ ServerName mywebsite.com ServerAlias www.mywebsite.com ErrorLog “logs/mywebsite.com-error_log“ CustomLog “logs/mywebsite.com-access_log” common

```
It’s important to replace `/usr/local/apache/htdocs/mywebsite` with the path to the directory where your website’s files are located. Repeat the process for each of your websites.

1. Update the Hosts File: Update your hosts file (located by default in `etc/hosts`) to include your new server name and the IP address with which it’s associated. A typical hosts file looks like this:

```
127.0.0.1 localhost
127.0.0.1 mywebsite.com
```

1. Restart Apache: Finally, restart your Apache server for the changes to take effect. You can do this via the Apache service or by rebooting your server (if possible).

1. Test Your Sites: Open a web browser and type the ServerName of each of your sites in the address bar (for example, `http://mywebsite.com`). Each one should bring up the correct website. If not, there may be a problem with your configuration or your DNS may not be set up correctly.

Remember, it’s important to update DNS records to ensure the domains point to the correct public IP of your server.

Once you’ve completed this process for all the websites you wish to host, you should be able to manage all of the websites on your Apache server through these virtual hosts you’ve set up. Make sure to regularly update and backup your server configuration files to ensure stability and security.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use