Setting Up an Apache Virtual Host for Joomla
This tutorial configures Apache to serve your Joomla site at /var/www/html/mySite using a custom local domain (e.g. mySite.local) instead of http://127.0.0.1/mySite.
Prerequisites
- Apache installed (part of your LAMP stack)
- Joomla site already at
/var/www/html/mySite - Root/sudo access
1. Create the Virtual Host Config File
Paste the following:
ApacheConf
<VirtualHost *:80>
ServerName mySite.local
ServerAlias www.mySite.local
DocumentRoot /var/www/html/mySite
<Directory /var/www/html/mySite>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mySite_error.log
CustomLog ${APACHE_LOG_DIR}/mySite_access.log combined
</VirtualHost>
AllowOverride Allis important for Joomla, since it relies on.htaccessfor SEF (search engine friendly) URLs.
2. Enable the Site and Required Modules
3. Add the Local Domain to Hosts File
Add this line:
4. Restart Apache
5. Test It
Open your browser and go to:
You should see your Joomla site load.
6. Update Joomla's Site URL
Joomla stores its base URL in the database. If you switch from http://127.0.0.1/mySite to http://mySite.local, update it:
- Log in to Joomla admin at
http://mySite.local/administrator - Go to System → Global Configuration
- Update the Site URL field (if present) — or check
configuration.phpin your Joomla root:
Look for and update:
Troubleshooting
| Issue | Fix |
|---|---|
| 403 Forbidden | Check folder permissions: sudo chown -R www-data:www-data /var/www/html/mySite |
| .htaccess not working | Confirm AllowOverride All and a2enmod rewrite was run |
| Domain doesn't resolve | Double-check /etc/hosts entry and clear browser DNS cache |
| Apache won't restart | Run sudo apache2ctl configtest to find syntax errors |
Notes
- If you're running multiple Joomla sites, repeat this process with a unique
ServerNameand.conffile per site. - Consider adding this vhost to Nginx Proxy Manager later if you want SSL or a reverse proxy in front of it.