Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 禁止,你不';您没有访问此资源的权限_Apache_Ubuntu 18.04 - Fatal编程技术网

Apache 禁止,你不';您没有访问此资源的权限

Apache 禁止,你不';您没有访问此资源的权限,apache,ubuntu-18.04,Apache,Ubuntu 18.04,我正在尝试使用apach2在ubuntu中创建一个名为sitb的站点。我创建了一个html文件,并将其保存在var/www中创建的siteb文件夹中,但当我加载该站点时,它只是说禁止,您没有访问此资源的权限。我不知道为什么我会得到这个,因为我将siteb的权限设置为755 这是我的/etc/apache2/apache2.conf文件 # This is the main Apache server configuration file. It contains the # configura

我正在尝试使用apach2在ubuntu中创建一个名为sitb的站点。我创建了一个html文件,并将其保存在var/www中创建的siteb文件夹中,但当我加载该站点时,它只是说禁止,您没有访问此资源的权限。我不知道为什么我会得到这个,因为我将siteb的权限设置为755

这是我的/etc/apache2/apache2.conf文件

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#   /etc/apache2/
#   |-- apache2.conf
#   |   `--  ports.conf
#   |-- mods-enabled
#   |   |-- *.load
#   |   `-- *.conf
#   |-- conf-enabled
#   |   `-- *.conf
#   `-- sites-enabled
#       `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/default>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/siteb>
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
</Directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
#这是主要的Apache服务器配置文件。它包含
#为服务器提供指令的配置指令。
#看http://httpd.apache.org/docs/2.4/ 有关
#关于特定于Debian的指令和/usr/share/doc/apache2/README.Debian
#提示。
#
#
#Apache2配置如何在Debian中工作的摘要:
#Debian中的Apache2Web服务器配置与
#upstream建议的配置web服务器的方法。这是因为Debian的
#默认Apache2安装尝试添加和删除模块,
#虚拟主机,以及尽可能灵活的额外配置指令
#以便尽可能轻松地自动化更改和管理服务器
#可能。
#它被分割成几个文件,形成所概述的配置层次结构
#下面的所有文件都位于/etc/apache2/目录中:
#
#/etc/apache2/
#|--apache2.conf
#|`--ports.conf
#|--mods已启用
#| 124;--*.装载
#|`-*.conf
#|--conf已启用
#|`-*.conf
#`--已启用站点
#`-*.conf
#
#
#*apache2.conf是主配置文件(此文件)。它把碎片
#在启动时包括所有剩余的配置文件
#网络服务器。
#
#*ports.conf始终包含在主配置文件中。它是
#应该确定传入连接的侦听端口,这些端口可以
#随时定制。
#
#*mods enabled/、conf enabled/和sites enabled中的配置文件/
#目录包含管理模块的特定配置代码段,
#全局配置片段或虚拟主机配置,
#分别。
#
#它们通过将其上的可用配置文件符号链接来激活
#相应*-可用/副本。这些应该通过使用我们的
#助手a2enmod/a2dismod、a2ensite/a2disconf和a2enconf/a2disconf。看见
#有关详细信息,请参阅各自的手册页。
#
#*二进制文件称为apache2。由于使用了环境变量,在
#默认配置apache2需要使用启动/停止
#/etc/init.d/apache2或apache2ctl。直接调用/usr/bin/apache2不会
#使用默认配置。
#全局配置
#
#
#ServerRoot:目录树的顶部,服务器的
#保留配置、错误和日志文件。
#
#注意!如果要将其放置在NFS(或其他网络)上
#然后请阅读互斥文件系统文档(可用
#at);
#你会省去很多麻烦。
#
#不要在目录路径的末尾添加斜杠。
#
#ServerRoot“/etc/apache2”
#
#接受序列化锁定文件必须存储在本地磁盘上。
#
#互斥文件:${APACHE\u LOCK\u DIR}默认值
#
#存储shm和其他运行时文件的目录。
#
DefaultRuntimeDir${APACHE\u RUN\u DIR}
#
#PidFile:服务器应在其中记录其进程的文件
#启动时的标识号。
#这需要在/etc/apache2/envvars中设置
#
PidFile${APACHE_PID_文件}
#
#超时:接收和发送超时之前的秒数。
#
超时300
#
#KeepAlive:是否允许持久连接(超过
#每个连接一个请求)。设置为“关闭”以停用。
#
继续
#
#MaxKeepAliverRequests:允许的最大请求数
#在持久连接期间。设置为0以允许无限量。
#我们建议您将此数字保持在较高水平,以获得最佳性能。
#
MaxKeepAliveRequests 100
#
#KeepAliveTimeout:等待来自的下一个请求的秒数
#同一连接上的同一客户端。
#
保持超时
#这些需要在/etc/apache2/envvars中设置
用户${APACHE\u RUN\u User}
组${APACHE\u RUN\u Group}
#
#HostnameLookups:记录客户机的名称或仅记录其IP地址
#例如,www.apache.org(开)或204.62.129.132(关)。
#默认设置是关闭的,因为如果人们
#必须故意打开此功能,因为启用它意味着
#每个客户端请求将导致至少一个对客户端的查找请求
#名称服务器。
#
主机名查询
#ErrorLog:错误日志文件的位置。
#如果未在中指定ErrorLog指令
#容器中,将显示与该虚拟主机相关的错误消息
#在这里登录。如果您*确实*为
#容器,该主机的错误将记录在那里而不是这里。
#
ErrorLog${APACHE_LOG_DIR}/error.LOG
#
#日志级别:控制记录到错误日志的消息的严重性。
#可用值:trace8、…、trace1、调试、信息、通知、警告、,
#错误、暴击、警报、紧急情况。
#还可以为特定模块配置日志级别,例如。
#“日志级别信息ssl:警告”
#
日志级别警告
#包括模块配置:
包括可选mods启用/*.加载
IncludeOptional mods enabled/*.conf
#包括要侦听的端口列表
Include ports.conf
#设置Apache2 HTTPD服务器的默认安全模型。是的
#不允许访问/usr/share和/var/www之外的根文件系统。
#前者由Debian中打包的web应用程序使用,
#后者可用于web服务器提供服务的本地目录。如果
#您的系统正在为/srv中您必须允许的子目录中的内容提供服务
#访问此处或任何相关虚拟主机。
选项如下符号链接
不允许超限
要求全部拒绝
不允许超限
要求所有授权
选项索引跟随符号链接
不允许超限
cd /etc/apache2/sites-available/
ls -la
cat 000-default.conf
cd /etc/apache2/sites-available/
sudo cp 000-default.conf example.com.conf
sudo mkdir /var/www/example.com
sudo mkdir /var/www/example.com/public_html
sudo echo '<h1>This is the index file of example.com' > /var/www/example.com/public_html/index.html
sudo chown -R 775 /var/www/example.com/
sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite example.com.conf
sudo a2dissite 000-default.conf
sudo service apache2 restart