Home > Backend Development > PHP Tutorial > About php Apache configuration virtual host

About php Apache configuration virtual host

迷茫
Release: 2023-03-06 22:24:02
Original
2298 people have browsed it

Take Apache version 2.4 as an example

1. Modify httpd.conf

Remove the # in the second line below and start the virtual host configuration

# Virtual hosts  # Include conf/extra/httpd-vhosts.conf
Copy after login

2. Configure httpd-vhost.conf

Port 8081 is used here, and two virtual hosts are configured. DocumentRoot cannot contain Chinese directories

<VirtualHost *:8081>  
    ServerName localhost
    DirectoryIndex index.php   
    DocumentRoot "D:\Work\php\Apache24\htdocs"  
    <Directory "D:\Work\php\Apache24\htdocs">   
        Options Indexes FollowSymLinks   
        AllowOverride None   
        Order allow,deny   
        Allow from all   
    </Directory>   
</VirtualHost>  

<VirtualHost *:8081>  
    ServerName www.aa.com
    DirectoryIndex index.php   
    DocumentRoot "E:\php\PhpProjectBase"  
    <Directory "E:\php\PhpProjectBase">   
        Options Indexes FollowSymLinks   
        AllowOverride None   
        Order allow,deny   
        Allow from all   
    </Directory>   
</VirtualHost>
Copy after login

3. etc/hosts configuration

127.0.0.1 localhost127.0.0.1 www.aa.com
Copy after login

4. Restart the Apache service

If the virtual host is still inaccessible at this time, configure the following items in httpd.conf

<Directory />
    AllowOverride none    #Require all denied</Directory>
Copy after login

The above is the detailed content of About php Apache configuration virtual host. For more information, please follow other related articles on the PHP Chinese website!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template