Home>Article>Backend Development> How to use Apache to build a virtual host

How to use Apache to build a virtual host

jacklove
jacklove Original
2018-06-11 10:45:21 2661browse

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

 ServerAdmin webmaster@localhost DirectoryIndex index.html index.php DocumentRoot /home/fdipzone/sites/demo.fdipzone.com ServerName demo.fdipzone.com ServerAlias demo.fdipzone.com  allow from all Options + Indexes  

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

 AllowOverride none AllowOverride all Options -Indexes FollowSymLinks 

AllowOverride nonemeans closing .htaccess. If you want to enable it, set it toAllowOverride all
Options -Indexesmeans closing the directory Structure display, if you want to turn it on, you can set it toOptions Indexes
Options FollowSymLinks, which means it supports symbol link (soft link). If you want to turn it off, you can set it toOptions -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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn