Five steps to solve the problem
1. Edit httpd.conf and introduce the vhosts configuration file
Find
vhosts.conf
, delete its previous#
number
Note: You can also create a virtual host configuration file yourself, usingInclude+配置文件路径
the introduction to
Two, edit the vhosts configuration file
Open
APACHE_HOME/conf/extra/httpd-vhosts.conf
or你新创建的文件
, add the following<VirtualHost *:LISTEN_PORT> ServerAdmin [email protected] DocumentRoot "指定你的路径" ServerName example.net ServerAlias example.net ErrorLog "logs/vhosts.log" CustomLog "logs/vhosts.log" common # 如果 index 是 php 文件,那就必须要配置 index.php,或者你想展示的首页文件名 # DirectoryIndex index.php <Directory "上面指定你的路径"> # -Indexes 是在没有 index 文件时不展示目录结构,可以看自己需求决定是否打开 Options -Indexes +FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
Note:
① If there had been changes tohttpd.conf
the port after the LISTEN, modify the configuration textLISTEN_PORT
you specified port
② Please keep only what you need and effective configuration of vhosts in the configuration file, remove excess
3. Edit the hosts file and add domain name resolution
Open
C:\Windows\System32\drivers\etc\hosts
file is added to the inside, whichdomain
needsvhosts.conf
the configuration fileServerName
orServerAlias
, the matching any one or all of which may127.0.0.1 example.net ::1 example.net
It is not recommended to use a domain name like css.dev , the actual test Chrome browser will not be able to request, I don’t know what caused it,
Fourth, restart Apache
- Use ApacheMonitor to restart Apache
Open the
APACHE_HOME/bin
nextApacheMonitor.exe
restart from the task bar, if not start, you can directly Start (after a successful start will turn green Apche2.4 ago)
from the main interface to restart the ApacheMonitor (choose any of it)
- Restart Apache from the service
Ctrl+ Alt+ ESCStart Task Manager, open the
服务
tab, find Apache2.4, right-click to select Start (or restart)
Five, verify that the configuration is successful
Use any browser to open your configured domain name.
Note: If you modify the port of LISTEN in httpd.conf, please add : + your designated port after the domain name for access, such as
Congratulations, you have solved this problem, continue to overcome the next difficulty!
Still have minor problems?
Apache2.4
Version Do not<Directory>
use the labelOrder allow,deny
, orallow from all
other statements, can cause Apache failed to start because the new version does not support these two statements!- You can leave a message below and I will try to solve it for you!