资讯专栏INFORMATION COLUMN

magento第二课:使用Apache web服务器搭建网站

loostudy / 1088人阅读

摘要:官方文档配置文件这是主要的服务器配置文件,它包含一些服务器的配置指令,详情参考及查看特殊提示在中配置工作概述,它与服务器的配置有一些区别被分割成了多个文件,但所有的配置文件还是在文件夹中是主配置文件

apache2官方文档 http://httpd.apache.org/docs/...

配置文件
# 这是apache主要的服务器配置文件,它包含一些服务器的配置指令,详情参考 http://httpd.apache.org/docs/2.4/ 及查看Debian特殊提示 /usr/share/doc/apache2/README.Debian 
#
#
# 在Debian中Apache2配置工作概述,它与web服务器的配置有一些区别

# 被分割成了多个文件,但所有的配置文件还是在 /etc/apache2/ 文件夹中
#
#    /etc/apache2/
#    |-- apache2.conf
#    |    `--  ports.conf
#    |-- mods-enabled
#    |    |-- *.load
#    |    `-- *.conf
#    |-- conf-enabled
#    |    `-- *.conf
#     `-- sites-enabled
#         `-- *.conf
#
#
# * apache2.conf 是主配置文件. 
#
# * ports.conf 最终是包含到上面的主配置文件中. 
#
# * 在mods-enabled/, conf-enabled/ 和 sites-enabled/这几个目录下的配置文件,分别用来管理模块、全局配置片段,虚拟主机配置
#   它们都是 *-available文件夹下的一个符号链接,也就是同windows下的快捷方式是同一种类型,对于是否启用的管理,可以使用以下命令
#   如开启rewrite模块,使用 root@ubuntu:~# a2enmod rewrite,会生成链接/etc/apache2/mods-enabled/rewrite.load,关闭是 a2dismod rewrite
#   同样对虚拟主机命令有 a2ensite和a2dissite,对全局配置有 a2enconf∑ a2disconf
#
# * 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.


# 全局配置
#

#
# ServerRoot: 目录树的顶部,它下面放服务器的配置文件、错误和日志文件
#
# 提示!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at );
# you will save yourself a lot of trouble.
#
# 不要在目录的结尾加斜杠
#
#ServerRoot "/etc/apache2"

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

#
# 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 
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a 
# container, that host"s errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# 日志级别: 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

# 导入模块配置文件:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# 导入需要侦听端口的列表
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.

    Options FollowSymLinks
    AllowOverride None
    Require all denied



    AllowOverride None
    Require all granted



    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted


#
#    Options Indexes FollowSymLinks
#    AllowOverride None
#    Require all granted
#




# AccessFileName: 会在每个文件夹中查该文件,它包含一些附加配置指令,也可参阅指令 AllowOverride
#
AccessFileName .htaccess

#
# FilesMatch是一个正则表达式,表示以.ht开头的文件,下面的意思是,象.htaccess 和 .htpasswd这一类以.ht开头的文件,不能被web客户端浏览

    Require all denied



#
# 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

# 导入虚拟主机的配置:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

虚拟主机设置
参考指令 http://httpd.apache.org/docs/...
建配置文件/etc/apache2/sites-available/www.chuse.store.conf,内容如下


    ServerAdmin wang@chuse.store
    DocumentRoot /var/www/chuse/store
    ServerName www.chuse.store
    ErrorLog /var/log/apache2/www.chuse.store-error_log
    TransferLog /var/log/apache2/www.chuse.store-access_log

启动网站

root@ubuntu:~# a2ensite www.chuse.store.conf
root@ubuntu:~# service apache2 restart

建一个测试文件 /var/www/chuse/store/index.php

修改宿主机中C:WindowsSystem32driversetchosts,加一行127.0.0.1 www.chuse.store

目录映射

参考 https://www.jianshu.com/p/223...
参考 https://www.cnblogs.com/xing9...

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/35921.html

相关文章

  • Magento2.0安装详细教程

    摘要:点击开始检查你的本地计算机环境是否符合安装的要求。解决刚才遇到的问题后,重新检查环节,,即可看到环境符合安装的要求,将会看到如下图所示。接着点击下一步,没有太多要说的,接着下一步下一步傻瓜式点击下一步到此,安装结束。 1.环境要求:Apache: 2.2 or 2.4PHP: >=5.4.11 or 5.5xMySQL: 5.6x1.首先安装好XAMPP集成开发环境包(其他集成开发环境...

    sewerganger 评论0 收藏0
  • 谈一谈云务器和主机建站配置要求 - 搭建网站需要的主机配置方案-老部落

    摘要:老蒋经常看到有网友询问搭建网站的时候主机和云服务器到底如何选择及建站要求建站要求。第二机房选择定位云服务器或者主机商的机房还是有很多的。当然,前者是需要备案的,后者亚洲机房不要备案。配置要求,我们还需要根据系统或者项目来决定。 老蒋经常看到有网友询问搭建网站的时候主机和云服务器到底如何选择及建站要求。比如对于主机商的选择、主机机房,以及配置要求等。确实,我们在看到各个云...

    Barry_Ng 评论0 收藏0
  • Vue.js学习二课 如何安装

    摘要:安装独立版本我们可以在的官网上直接下载并用标签引入。国内会保持和发布的最新的版本一致。方法由于安装速度慢,本教程使用了淘宝的镜像及其命令,安装使用介绍参照使用淘宝镜像。 Vue.js 安装 1、独立版本 我们可以在 Vue.js 的官网上直接下载 vue.min.js 并用 标签引入。 2、使用 CDN 方法 以下推荐国外比较稳定的两个 CDN,国内还没发现哪一家比较好,目前还是建议...

    stefanieliang 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<