如标题所述,我出现了如下错误:
Forbidden
You don't have permission to access this resource.
Apache/2.4.38 (Uos) Server at localhost Port 80
我能够想到的是目录没有权限,因此对目录已经设置了权限
配置文件如下:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /home/leomus/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
<Directory "/home/leomus/www">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# or most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
期间我修改目录成var/www/html
成初始状态,但是无法运行php
**无法运行PHP的问题已经解决是缺少插件,安装相关组件即可运行PHP
安装组件命令如下**
sudo apt install php7.3-mysql php7.3-curl php7.3-gd php7.3-intl php-pear php7.3-imagick
但是仍然不能修改目录,这个目录是正常且路径是存在的。
我系统里面安装了PHP7.3
我实在找不出问题所在了,有知道兄弟麻烦解答一下,谢谢!
更改目录权限
确保目录及其所有子目录和文件具有正确的权限,通常使用
755
权限。具体操作步骤:更改目录所有者
确保 Apache 用户(通常是
www-data
或apache
)拥有该目录及其内容的所有权:确认Apache的运行用户和组与新目录的所有者和组一致。可以在/etc/apache2/envvars文件中设置Apache的运行用户和组:
如果Apache用户是apache
chown -R apache:apache /path/to/your/new/directory
ls -l /path/to/your/new/directory
drwxr-xr-x 2 www-data www-data 4096 Nov 9 21:58 your-directory
<Directory "/path/to/your/new/directory">
</Directory>
sudo systemctl restart apache2