Home > Article > Backend Development > How to use Apache to build a virtual host
Apache method to build a virtual host
DocumentRoot: /home/fdipzone/sites/demo.fdipzone.com
ServerName :demo.fdipzone.com
1. Enter the apache virtual host settings directory
cd /etc/apache2/sites-available
2. Create the file demo .fdipzone.com
<VirtualHost *:80> ServerAdmin webmaster@localhost DirectoryIndex index.html index.php DocumentRoot /home/fdipzone/sites/demo.fdipzone.com ServerName demo.fdipzone.com ServerAlias demo.fdipzone.com <Directory "/home/fdipzone/sites/demo.fdipzone.com"> allow from all Options + Indexes </Directory> </VirtualHost>
3. Activate virtual host configuration
sudo a2ensite demo.fdipzone.com
4. Enter the /etc/apache2/sites-enabled/ directory to view all activated virtual hosts. You can use sudo a2dissite demo.fdipzone.com to log out
cd /etc/apache2/sites-enabled ls -lt 显示 lrwxrwxrwx 1 root root 36 2013-04-05 17:29 demo.fdipzone.com -> ../sites-available/demo.fdipzone.com
5. Restart the apache service
sudo /etc/init.d/apache2 restart
6.ubuntu Set host
vim /etc/hosts 127.0.0.1 demo.fdipzone.com
7.7b799fe73e35dcfdc019b13f54de80e5Set to open .htaccess and display directory structure list
<Directory "/home/fdipzone/demo.fdipzone.com"> AllowOverride none AllowOverride all Options -Indexes FollowSymLinks </Directory>
AllowOverride none means closing .htaccess. If you want to enable it, set it to AllowOverride all
Options -Indexes means closing the directory Structure display, if you want to turn it on, you can set it to Options Indexes
Options FollowSymLinks, which means it supports symbol link (soft link). If you want to turn it off, you can set it to Options -FollowSymLinks
This article introduces how to use Apache to build a virtual host. For more related content, please pay attention to the php Chinese website.
related suggestion:
The above is the detailed content of How to use Apache to build a virtual host. For more information, please follow other related articles on the PHP Chinese website!