search
Homephp教程php手册apache配置多站点,apache配置站点

apache配置多站点,apache配置站点

在httpd.conf文件中,有如下配置(注:舍去httpd.conf文件的注释内容)

Listen 80
ServerName localhost
<directory></directory>
    AllowOverride none
    Require all denied



DocumentRoot "E:"
<directory>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</directory>



(测试之前最好清理一下浏览器缓存),那么在浏览器中输入http://localhost/Workshop/Apache/ 便可以访问E:/Workshop/Apache下的所有文件,注意此处的根目录是E:,但是上面的那个Directory设置了权限所以无法访问E盘下面的所有内容,如果将上面的那个Directoy更改为:


<directory></directory>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted



那么便可以从浏览器中访问E盘的所有东西,当在浏览器中输入localhost的时候,浏览器将会显示E盘根目录下的所有内容,并且可以访问。为了安全,我们通常不这么做,因此经常的设置方法是下面这样的配置:


Listen 80
ServerName localhost
<directory></directory>
    AllowOverride none
    Require all denied



DocumentRoot "E:/Workshop/Apache"
<directory>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</directory>



通过浏览器只允许访问特定目录,此处也就是E:/Workshop/Apache目录下的所有内容。当然对于第二个Dir,可以设置E:/Workshop/Apache下不同文件夹的访问权限。


最后说一下虚拟主机的设置,请按照以下格式设置(放在httpd.conf文件末尾即可):


如下所示,需要首先设置监听端口,然后是NameVirtualHost指定主机地址以及端口,接下来就是对VirtualHost进行设置了,其中包括SeverName也就是主机名以及文档根目录,注意对于本地开发时,将ServerName设置为localhost或者127.0.0.1即可,其中的文档根目录与目录设置一样即可,或者你也可以在文档根目录中为不同的文件夹设置不同的访问权限。其中的×号代表监听所有访问设置端口的虚拟主机。

Listen 81
NameVirtualHost *:81
<virtualhost>
    ServerName 127.0.0.1
    DocumentRoot "C:/Users/Administrator/php/webroot1"
    <directory>
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</directory>
</virtualhost>


Listen 82
NameVirtualHost ×:82
<virtualhost>
    ServerName 127.0.0.1
    DocumentRoot "C:/Users/Administrator/php/webroot2"
    <directory>
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</directory>
</virtualhost>
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.