Table of Contents
apache配置多站点,apache配置站点
Home php教程 php手册 apache配置多站点,apache配置站点

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

Jun 13, 2016 am 09:03 AM
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>
Copy after login



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


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



那么便可以从浏览器中访问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>
Copy after login



通过浏览器只允许访问特定目录,此处也就是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>
Copy after login
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run the h5 project How to run the h5 project Apr 06, 2025 pm 12:21 PM

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

How to export pdf with xml How to export pdf with xml Apr 03, 2025 am 06:45 AM

There are two ways to export XML to PDF: using XSLT and using XML data binding libraries. XSLT: Create an XSLT stylesheet, specify the PDF format to convert XML data using the XSLT processor. XML Data binding library: Import XML Data binding library Create PDF Document object loading XML data export PDF files. Which method is better for PDF files depends on the requirements. XSLT provides flexibility, while the data binding library is simple to implement; for simple conversions, the data binding library is better, and for complex conversions, XSLT is more suitable.

Apache Troubleshooting: Diagnosing & Resolving Common Errors Apache Troubleshooting: Diagnosing & Resolving Common Errors Apr 03, 2025 am 12:07 AM

Apache errors can be diagnosed and resolved by viewing log files. 1) View the error.log file, 2) Use the grep command to filter errors in specific domain names, 3) Clean the log files regularly and optimize the configuration, 4) Use monitoring tools to monitor and alert in real time. Through these steps, Apache errors can be effectively diagnosed and resolved.

How to generate pom.xml How to generate pom.xml Apr 03, 2025 am 06:00 AM

There are the following ways to generate a pom.xml file: Use Maven Archetype to provide predefined project templates to automatically generate pom.xml files for specific types of projects. Use the Maven Helper plugin to provide commands to generate pom.xml files. Create manually to customize the pom.xml file for the project.

How to set character encoding on the server side to solve Bootstrap Table garbled How to set character encoding on the server side to solve Bootstrap Table garbled Apr 07, 2025 pm 12:00 PM

To set character encoding on the server side to solve the garbled Bootstrap Table, you need to follow the following steps: check the server character encoding; edit the server configuration file; set the character encoding to UTF-8; save and restart the server; verify the encoding.

Cannot start mysql in xampp Cannot start mysql in xampp Apr 08, 2025 pm 03:15 PM

There are many reasons why XAMPP fails to start MySQL, including port conflicts, configuration file errors, insufficient system permissions, service dependency issues, and installation issues. The troubleshooting steps are as follows: 1) Check port conflicts; 2) Check configuration files; 3) Check system permissions; 4) Check service dependencies; 5) Reinstall MySQL. Follow these steps and you can find and resolve issues that cause MySQL startup to fail.

How to preview the Bootstrap page How to preview the Bootstrap page Apr 07, 2025 am 10:06 AM

The preview methods of Bootstrap pages are: open the HTML file directly in the browser; automatically refresh the browser using the Live Server plug-in; and build a local server to simulate an online environment.

Summary of phpmyadmin vulnerabilities Summary of phpmyadmin vulnerabilities Apr 10, 2025 pm 10:24 PM

The key to PHPMyAdmin security defense strategy is: 1. Use the latest version of PHPMyAdmin and regularly update PHP and MySQL; 2. Strictly control access rights, use .htaccess or web server access control; 3. Enable strong password and two-factor authentication; 4. Back up the database regularly; 5. Carefully check the configuration files to avoid exposing sensitive information; 6. Use Web Application Firewall (WAF); 7. Carry out security audits. These measures can effectively reduce the security risks caused by PHPMyAdmin due to improper configuration, over-old version or environmental security risks, and ensure the security of the database.

See all articles