How to Create an Apache Virtual Host on Linux (Debian/Ubuntu)
HardReset.InfoJanuary 18, 202610 min18 views
17 connectionsΒ·22 entities in this videoβApache Virtual Host Setup on Linux
- π‘ Apache installation is a prerequisite; check its status with
sudo systemctl status apache2. - π If Apache is stopped or disabled, use
sudo systemctl start apache2orsudo systemctl enable apache2.
Creating the Site Directory and Permissions
- π Create a directory for your new site using
mkdir -p /var/www/mysite.local/public_html. - π Set ownership and group with
sudo chown -R www-data:www-data /var/www/mysite.local/public_html. - βοΈ Apply permissions using
sudo chmod -R 755 /var/www/mysite.local/public_html.
Creating the Index File and Virtual Host Configuration
- π Create a simple
index.htmlfile in thepublic_htmldirectory usingnano. - π Define the virtual host configuration in
/etc/apache2/sites-available/mysite.local.conf. - π‘ Key directives include
ServerAdmin,ServerName,ServerAlias, andDocumentRootpointing to your site's directory. - ποΈ Configure
ErrorLogandCustomLogpaths within the virtual host file.
Enabling the Virtual Host and Testing
- π οΈ Enable the new virtual host with
sudo a2ensite mysite.local.conf. - π« Disable the default Apache site using
sudo a2dissite 000-default.conf. - β
Test the Apache configuration syntax with
sudo apachectl configtest. - π Restart Apache for changes to take effect:
sudo systemctl restart apache2. - π» Edit the hosts file (
sudo nano /etc/hosts) to mapmysite.localto127.0.0.1. - π Access your local domain (
http://mysite.local) in a web browser to confirm it's working.
Knowledge graph22 entities Β· 17 connections
How they connect
An interactive map of every person, idea, and reference from this conversation. Hover to trace connections, click to explore.
Hover Β· drag to explore
22 entities
Chapters4 moments
Key Moments
Transcript36 segments
Full Transcript
Topics14 themes
Whatβs Discussed
Apache Virtual HostApache2LinuxDebianUbuntuWeb Server ConfigurationLocal DevelopmentSystemctlChownChmodA2ensiteA2dissiteApachectl/etc/hosts
Smart Objects22 Β· 17 links
ProductsΒ· 4
MediasΒ· 3
CompanyΒ· 1
ConceptsΒ· 13
LocationΒ· 1