How to use Apache to build a virtual host

jacklove
Release: 2023-03-31 13:26:02
Original
2644 people have browsed it

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
Copy after login

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  
Copy after login

3. Activate virtual host configuration

sudo a2ensite demo.fdipzone.com
Copy after login

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
Copy after login

5. Restart the apache service

sudo /etc/init.d/apache2 restart
Copy after login

6.ubuntu Set host

vim /etc/hosts 127.0.0.1 demo.fdipzone.com
Copy after login

7. Set to open .htaccess and display directory structure list

 AllowOverride none AllowOverride all Options -Indexes FollowSymLinks 
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!