Apache 2 & PHP 8 errors All In One
errors
You don‘t have permission to access this resource.
❌
http://www.webhacker.com/phpinfo.php
solutions
✅ 1. 修改 httpd.conf
配置文件, 把 "Require all denied" 修改成 Require all granted
/usr/local/etc/httpd/httpd.conf
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
# Require all denied
Require all granted
</Directory>
✅ 2. 修改 httpd-vhosts.conf
配置文件, 新增 <Directory />
配置,并开启 Require all granted
/usr/local/etc/httpd/extra/httpd-vhosts.conf
## PHP 8.1
<VirtualHost *:80>
ServerAdmin [email protected]
# DocumentRoot "/Library/WebServer/Documents"
# DocumentRoot "/usr/local/var/www"
DocumentRoot "/usr/local/var/php8"
# DocumentRoot "/usr/local/opt/httpd/docs/php8"
# DocumentRoot "/usr/local/opt/httpd/docs/www.webhacker.com"
<Directory />
AllowOverride none
# Require all denied
Require all granted
</Directory>
ServerName webhacker.com
ServerAlias www.webhacker.com
ErrorLog "/usr/local/var/log/httpd/www.webhacker.com-error_log"
CustomLog "/usr/local/var/log/httpd/www.webhacker.com-access_log" common
</VirtualHost>
demos
http://localhost:80/phpinfo.php
http://www.webhacker.com/phpinfo.php
Apache Environment
自定义 hosts 域名
test
http://localhost/xss.php?args=<script>alert("XSS