亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 網站 > Apache > 正文

apache2服務器的搭建和配置步驟詳解

2024-08-27 18:30:42
字體:
來源:轉載
供稿:網友

前言

這篇文章主要給大家介紹了在linux下apache2服務器的搭建和配置的相關資料,具有一定的參考價值,下面來一起學習學習吧。

步驟如下

首先當然是下載包包:

myths@myths-X450LD:~$ sudo apt-get install apache2

裝完后就可以用了,在地址欄輸入本地回送地址127.0.0.1或者localhost就可以進入到默認的界面了。

默認的界面當然就是apache2的說明界面了。其實很多情況下并不需要在網上尋找幫助文檔,幾乎所有的軟件都會自帶使用說明,只是略長,我們一般都懶得看。但是其實很多重要的東西就在這當中,比如apache2的默認界面里:

Ubuntu Logo Apache2 Ubuntu Default PageIt works!This is the default welcome page used to test the correct operation of the Apache2 server after installation on Ubuntu systems. It is based on the equivalent page on Debian, from which the Ubuntu Apache packaging is derived. If you can read this page, it means that the Apache HTTP server installed at this site is working properly. You should replace this file (located at /var/www/html/index.html) before continuing to operate your HTTP server.If you are a normal user of this web site and don't know what this page is about, this probably means that the site is currently unavailable due to maintenance. If the problem persists, please contact the site's administrator.Configuration OverviewUbuntu's Apache2 default configuration is different from the upstream default configuration, and split into several files optimized for interaction with Ubuntu tools. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full documentation. Documentation for the web server itself can be found by accessing the manual if the apache2-doc package was installed on this server.The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:/etc/apache2/|-- apache2.conf|  `-- ports.conf|-- mods-enabled|  |-- *.load|  `-- *.conf|-- conf-enabled|  `-- *.conf|-- sites-enabled|  `-- *.confapache2.conf is the main configuration 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 used to determine the listening ports for incoming connections, and this file 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.Document RootsBy default, Ubuntu does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in /etc/apache2/apache2.conf.The default Ubuntu document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.Reporting ProblemsPlease use the ubuntu-bug tool to report bugs in the Apache2 package with Ubuntu. However, check existing bug reports before reporting a new bug.Please report bugs specific to modules (such as PHP and others) to respective packages, not to the web server itself.Valid XHTML 1.0 Transitional

僅僅從這個文件中,我們就可以至少得到以下的重要信息:

  • 當訪問本機的時候,默認進入的頁面是/var/www/html/index.html。
  • 配置系統的說明在/usr/share/doc/apache2/README.Debian.gz中。
  • 完整使用手冊可以通過安裝apache2-doc 進行下載。
  • 主配置文件為/etc/apache2/apache2.conf。
  • 啟動和關閉apache2服務可以通過執行命令/etc/init.d/apache2 start(stop / restart)當然也可以是 service apache2 start (stop / restart)。這里一定要注意記得!記得!加root權限!這里不加root權限并沒有明顯的提示(好坑),當遇到問題的時候很難讓人想到是這里出的錯,所以一定要記得!記得!加root權限!
  • 默認情況下apache2拒絕訪問除/var/www 和/usr/share文件夾外的其他文件,這種權限是通過apache2.conf文件來控制的.

默認的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## 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/envvarsUser ${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/*.loadIncludeOptional mods-enabled/*.conf# Include list of ports to listen onInclude 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 /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_combinedLogFormat "%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combinedLogFormat "%h %l %u %t "%r" %>s %O" commonLogFormat "%{Referer}i -> %U" refererLogFormat "%{User-agent}i" agent# Include of directories ignores editors' and dpkg's backup files,# see README.Debian for details.# Include generic snippets of statementsIncludeOptional conf-enabled/*.conf# Include the virtual host configurations:IncludeOptional sites-enabled/*.conf# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

注意這當中的一段:

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

由這段可以很容易的知道apache2到底為哪些文件夾賦予了打開的權限了。以后就可以通過修改這里達到各種不可告人的目的了。

最后還有一個重要的配置,就是默認目錄的更改。默認的目錄其實是記錄在:/etc/apache2/sites-available/000-default.conf 文件當中(在/etc/apache2/sites-enable/中也有一個指向他的鏈接):

myths@myths-X450LD:/etc/apache2/sites-available$ cat 000-default.conf <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 /var/www/html # 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 ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For 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

當中的“DocumentRoot ”鍵對應的值就是默認的目錄了,可以任由我們修改了。

apache2的簡單配置基本就是這些,不需要百度,我們也是完全可以自己弄清楚的。

注:

  • 修改完配置文件后記得重啟服務
  • 可以順手吧/var/www的權限設置為777方便修改網頁

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網的支持。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久影视电视剧免费网站清宫辞电视| 色偷偷91综合久久噜噜| 久久久久久网站| 免费91在线视频| 操91在线视频| 日韩电视剧免费观看网站| 欧美伦理91i| 久久精品99久久久久久久久| 日韩三级影视基地| 精品一区二区三区四区在线| 亚洲精品国产精品久久清纯直播| 91社影院在线观看| 成人免费在线视频网址| 91精品久久久久久久久中文字幕| 欧美视频专区一二在线观看| 欧美最猛黑人xxxx黑人猛叫黄| 国产97在线|亚洲| 国产97在线视频| 亚洲欧美中文日韩在线| 秋霞av国产精品一区| 国产亚洲欧美一区| 日韩有码在线观看| 一区二区三区四区视频| 日韩免费av一区二区| 成人久久18免费网站图片| 日韩精品视频免费| 亚洲精品色婷婷福利天堂| 色噜噜狠狠狠综合曰曰曰88av| 欧美黑人一区二区三区| 国产精品国产三级国产专播精品人| 91久久久久久久一区二区| 国产精品视频一| 国产亚洲视频中文字幕视频| 久久国产精品久久久久久久久久| 日韩亚洲国产中文字幕| 久热99视频在线观看| 欧美一级在线亚洲天堂| 97久久精品人人澡人人爽缅北| 国产精品美女www爽爽爽视频| 亚洲国产精品久久久久| 精品国产一区二区三区久久| 国产福利视频一区二区| 亚洲日韩第一页| 国产美女直播视频一区| 热久久免费视频精品| 久久男人资源视频| 精品久久中文字幕| 97精品视频在线播放| 日韩欧美视频一区二区三区| 久久久精品2019中文字幕神马| 57pao国产精品一区| 国产成人精品在线视频| 一个人看的www久久| 亚洲一区二区精品| 国产综合视频在线观看| 日韩欧美在线字幕| 亚洲精选中文字幕| 久久精品国产一区二区三区| 性色av一区二区三区| 国产在线98福利播放视频| 国产97色在线| 欧美中文字幕视频| 久久精品最新地址| 88国产精品欧美一区二区三区| 亚洲电影av在线| 日本成人黄色片| 久久精品国产一区| 欧美成人午夜激情在线| 欧美国产视频一区二区| 成人免费激情视频| 欧美一乱一性一交一视频| 欧美性猛交xxxx免费看漫画| 97超级碰碰人国产在线观看| 青草青草久热精品视频在线网站| 亚洲第一页在线| 91久久精品视频| 成人免费在线网址| 亚洲资源在线看| 国产精品高潮在线| 久久亚洲综合国产精品99麻豆精品福利| 亚洲欧美中文日韩在线v日本| 亚洲成人av资源网| 日韩中文av在线| 国产精品一区二区三区在线播放| 欧美电影电视剧在线观看| 中文字幕日韩视频| 欧美精品情趣视频| 国产精品视频地址| 精品国产依人香蕉在线精品| 在线播放日韩欧美| 日韩中文字幕在线观看| 亚洲a级在线观看| 中文字幕在线日韩| 亚洲欧美日韩精品| 亚洲日本成人女熟在线观看| 成人激情视频在线观看| 中文字幕亚洲无线码在线一区| 91久久综合亚洲鲁鲁五月天| 成人黄色大片在线免费观看| 九九热99久久久国产盗摄| 欧美激情精品久久久久久大尺度| 欧美www视频在线观看| 亚洲理论在线a中文字幕| 欧美性猛交xxxx富婆弯腰| 欧美成人午夜激情在线| 97色在线视频| 亚洲一区二区三区视频播放| 亚洲欧洲成视频免费观看| 精品国产成人av| 久久视频在线观看免费| 一夜七次郎国产精品亚洲| 国产精品v日韩精品| 成人精品福利视频| 96精品久久久久中文字幕| 青草青草久热精品视频在线网站| 日韩视频第一页| 久久91超碰青草是什么| 欧美在线视频播放| 欧美一级大片在线观看| 欧美日韩久久久久| 国产午夜一区二区| 国产91精品久久久久久久| 亚洲欧美日韩在线一区| 欧美最顶级丰满的aⅴ艳星| 国产精品九九九| 午夜精品久久久久久久99热浪潮| 久久久久久久影院| 亚洲免费精彩视频| 国产成人精品视频在线观看| 秋霞午夜一区二区| 国产剧情久久久久久| 久久精品国产96久久久香蕉| 国产区精品视频| 乱亲女秽乱长久久久| 尤物yw午夜国产精品视频明星| 88国产精品欧美一区二区三区| 精品久久中文字幕久久av| 亚洲va久久久噜噜噜久久天堂| 国产精品久久久久9999| 国产精品高潮呻吟久久av黑人| 国产精品美腿一区在线看| 欧美日韩在线一区| 91精品国产高清自在线看超| 亚洲精品国产拍免费91在线| 日韩激情视频在线| 亚洲国产精品久久91精品| 岛国视频午夜一区免费在线观看| 亚洲激情国产精品| 亚洲欧美综合v| 亚洲色图欧美制服丝袜另类第一页| 日韩精品视频免费在线观看| 在线视频日本亚洲性| 国产一区二区精品丝袜| 亚洲午夜色婷婷在线| 免费不卡欧美自拍视频| 欧美人成在线视频| 日韩中文在线视频| 精品美女永久免费视频| 国产精品夜间视频香蕉| 欧美激情在线视频二区| 欧美孕妇性xx| 91夜夜未满十八勿入爽爽影院| 成人亚洲欧美一区二区三区| 中文字幕亚洲二区|