Home Backend Development PHP Tutorial Apache服务器高级设置指南_PHP

Apache服务器高级设置指南_PHP

Jun 01, 2016 pm 12:36 PM
guide document server Table of contents set up advanced

Apache

  目前WWW Server软件有许多,能运行在linux下的也不少,有NCSA HTTPd Server、CERN HTTPd Server、pache、Netscape Fast Track Server、Zeus Server等。这些软件各有特色:NCSA(美国伊利诺斯大学的国家超级计算应用中心)是WWW Browser Mosaic发迹之地,也是Netscape公司的安德森成名的地方;CERN(欧洲原子核研究中心)是WWW的起源地,1989年蒂姆·贝纳斯-李正是在这开发成功了世界上第一个Web服务器和客户机。这两家推出的WWW Server功能齐全,成为同类软件的标准,再加上它们都是Freeware,因此刚一推出就大受欢迎。前几年,在linux下WWW Server软件使用最多的是NCSA和CERN,但这一两年来,后起之秀Apache却独领风骚,号称"WWW Server之王"。在最新的Red Hat、Slackware和 OpenLinux各版本中都包含了Apache。

  Apache是在NCSA的基础上发展起来的,因此这二者的配置文件十分相似。

一、 安装

  Apache的安装十分简单。最好在安装RedHat时,选择安装Web Server,这样即使你对编译操作不熟的话,也能轻轻松松把服务器架设起来。

  如果你想亲自编译源文件,那么你已经不是一个初学者,建议你直接去看How-To文档或其他资料。打开机器,进入X-Window系统后,启动Netscape Navigator,敲入本机的IP地址,如果出现"It worked"的欢迎页面,那说明服务器程序工作正常。你可以进行下一步配置工作。在不同的版本下,服务器默认的工作根目录也不一样。Red Hat默认的是/etc/httpd,配置文件在/etc/httpd/conf目录下,页面文件在/home/httpd目录下。

二、 设置httpd.conf、srm.conf、access.conf文件

  Apache安装成功后,在conf子目录下有四个文件:httpd.conf、srm.conf、access.conf、magic(请注意:在www-howto文档中,说第四个文件是mime.types,但在实际安装中,在conf子目录下是magic文件)。httpd.conf是Apache设置文件中的主文件,httpd程序启动时会先读取httpd.conf。srm.conf是数据配置文件,在这个文件中主要设置WWW Server读取文件的目录、目录索引时的画面、CGI执行时的目录等等。access.conf是负责基本的读取文件控制,限制目录所能执行的功能及访问目录的权限设置。

  下面将简单对这三个数据设置文件进行说明。

httpd.conf文件

  TransferLog:

  如果你想知道你的网站上哪个页面最受来访者的欢迎,在一段时间内有多少人访问你的站点,你当然可以设置一个计数器,但每页都设计数器,太繁琐而且得到的结果不太可靠。最好的办法是查看相应log文件,TransferLog命令就是指定当浏览器要求服务器传送文件时记录到所设置的文件,可以根据此文件查看有哪些用户看过哪些HTML文件。可用一些程序分析这个文件的数据,得出监测各种有用的数据。默认的访问log文件是logs/access_log。

  ErrorLog:

  这个命令是指定当WWW Server运转过程中发生问题时错误信息存放到哪个文件。默认是logs/error_log。

  VirtualHost:

  这个命令是用来设置虚拟主机,即用一台主机执行多个域名的WWW Server。详细命令使用将在第三部分详细解释。

srm.conf

  DocumentRoot:

  指定WWW Server存放html文件的根目录。WWW Server从硬盘中读取html文件传送给浏览器,并不是可从任一个目录中读取文件,而是从一个特定目录中开始读取文件,这个特定的目录就是由DocumentRoot命令来指定。red hat5.2中默认的目录是/home/httpd/html。

  如果用户访问http://www.swm.com.cn/netlife/index.html,此时WWW Server并不是从系统的根目录下的netlife目录中读取index.html,而是从/home/httpd/html/netlife目录中读取index.html文件。
UserDir:

  如果要在WWW Server上给一些用户开设空间,搁放个人主页,最好不要把每个人的html文件都放到DocumentRoot目录中,用UserDir命令可让每个人的页面放置在自己的home目录中。默认的目录是public_html。

  如果UserDir设置的目录是public_html,而Username是yan,而该user的home目录是/home/yan,那你访问http://www.swm.com.cn/~yan/intr.html时所看到的intr.html文件存放在/home/yan/public_html中,而不是/home/httpd/html。

 access.conf

  如果你有些目录只想让某些人访问,或者只允许在特定的目录下允许CGI程序,这时就要对access.conf进行修改。

  Apache的存取控制方式有两种:一是"整体存取控制",只通过access.conf来控制文件的设置,来限定目录所能执行的功能及存取目录的权限设置。二是"特定目录存取控制",在特定目录中建立存取设置文件,这个文件名在srm.conf中的AcessFileName来决定,默认是.htaccess。例如某些目录中的文件只允许某些人访问,那可在该目录下建立.htaccess文件,当WWW Server读取该目录时便会自动读取.htaccess来决定是否读取执行或要求口令验证。这两种方式所使用的命令几乎相同,而且设置的格式也相同。 

  Directory:

  说明要设置的目录,然后再用命令来设置目录的功能和权限。

  Options:

  设置目录可以执行哪些功能。有None、All、ExecCGI、Includes、Indexs、IncludesNoExec、FollowSymlink、SymlinksOwnerMatch等选项。如果想让某个目录可以执行CGI程序,那么应在Options命令中加上ExecCGI选项。

  Require:

  设置可以对所指定目录以指定方式来存取的Users和Group。该命令执行后,当读取该目录数据时,系统会要求输入Username和Password。

  忠告:修改完设置文件后,不要像在Windows工作那样,重启机器使其生效。要记住,你现在linux下,使用linux的好处之一就是不用再见到Windows 98那死机时的蓝屏以及不必对配置文件做了一点点修改就无聊而又频繁地重启机器。你的WWW服务器任何时候都有很多人在访问,频繁地重启机器将把你的客人赶跑。要学会不重启机器,而是重新启动一个正执行的程序(Process,严格一点应叫做进程、作业)。可以用kill命令来使程序重新启动。具体kill的使用参见有关文档。

  先用ps命令查看httpd的pid号,然后用kill命令杀死它,重新启动httpd。具体命令如下:

    linux> ps -x
    linux> kill -HUP 13668

  (13668是假设httpd的pid号,在实际使用中,不同的情况值也不同)

  这样就可将httpd重新启动,使修改的配置文件生效。看完上面一大堆命令,是不是有些烦,其实你不了解这些命令也无所谓,用系统默认设置也能正常工作。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set the scheduled time for publishing works on Douyin? How does it set the video duration? How to set the scheduled time for publishing works on Douyin? How does it set the video duration? Mar 27, 2024 pm 06:11 PM

Publishing works on Douyin can attract more attention and likes, but sometimes it may be difficult for us to publish works in real time. In this case, we can use Douyin's scheduled release function. Douyin’s scheduled release function allows users to automatically publish works at a scheduled time, which can better plan the release plan and increase the exposure and influence of the work. 1. How to set the scheduled time for publishing works on Douyin? To set a scheduled release time, first go to Douyin's personal homepage, find the "+" button in the upper right corner, and click to enter the release page. There is a clock icon in the lower right corner of the publishing page. Click to enter the scheduled publishing interface. In the interface, you can choose the type of work you want to publish, including short videos, long videos, and live broadcasts. Next, you need to set a time for your work to be published. TikTok provides

Where is the Douyin tag set? How can it be tagged so that it can be pushed accurately? Where is the Douyin tag set? How can it be tagged so that it can be pushed accurately? Mar 27, 2024 am 11:01 AM

As one of the most popular short video platforms in the world, Douyin allows everyone to become a creator and share every moment of life. For Douyin users, tags are a very important function. It can help users better classify and retrieve content, and also allows the platform to push appropriate content to users more accurately. So, where are the Douyin tags set? This article will explain in detail how to set up and use tags on Douyin. 1. Where is the Douyin tag set? Using tags on Douyin can help users better classify and label their works, making it easier for other users to find and follow them. The method to set the label is as follows: 1. Open the Douyin APP and log in to your account. 2. Click the "+" sign at the bottom of the screen and select the "Publish" button. 3.

Do Not Disturb Mode Not Working in iPhone: Fix Do Not Disturb Mode Not Working in iPhone: Fix Apr 24, 2024 pm 04:50 PM

Even answering calls in Do Not Disturb mode can be a very annoying experience. As the name suggests, Do Not Disturb mode turns off all incoming call notifications and alerts from emails, messages, etc. You can follow these solution sets to fix it. Fix 1 – Enable Focus Mode Enable focus mode on your phone. Step 1 – Swipe down from the top to access Control Center. Step 2 – Next, enable “Focus Mode” on your phone. Focus Mode enables Do Not Disturb mode on your phone. It won't cause any incoming call alerts to appear on your phone. Fix 2 – Change Focus Mode Settings If there are some issues in the focus mode settings, you should fix them. Step 1 – Open your iPhone settings window. Step 2 – Next, turn on the Focus mode settings

How to set up scheduled publishing on Weibo_Tutorial on how to set up scheduled publishing on Weibo How to set up scheduled publishing on Weibo_Tutorial on how to set up scheduled publishing on Weibo Mar 29, 2024 pm 03:51 PM

1. Open the Weibo client, click the three little dots on the editing page, and then click Scheduled Post. 2. After clicking on scheduled posting, there will be a time option on the right side of the publishing time. Set the time, edit the article, and click on the yellow words in the lower right corner to schedule posting. 3. The mobile version of Weibo does not currently support scheduled publishing. This function can only be used on the PC client!

How to set the watermark in the middle on Weibo_How to set the watermark in the middle on Weibo How to set the watermark in the middle on Weibo_How to set the watermark in the middle on Weibo Mar 29, 2024 pm 03:31 PM

1. First enter Weibo, then click on me in the lower right corner and select [Customer Service]. 2. Then enter [Watermark] in the search box and select [Set Weibo Image Watermark]. 3. Then click [Link] in the interface. 4. Then click [Image Watermark Settings] in the newly opened window. 5. Finally, check [Picture Center] and click [Save].

Where to set Douyin recommendations and selections Where to set Douyin recommendations and selections Mar 27, 2024 pm 05:06 PM

Where are the recommendations and selections on Douyin? In Douyin short videos, there are two categories: selection and recommendation. Most users don’t know how to set up recommendations and selections. Next is the Douyin tutorial that the editor brings to users. Audio recommendations and selected setting method tutorials, interested users come and take a look! Douyin usage tutorial Where to set up Douyin recommendations and selections 1. First open the Douyin short video APP and enter the main page, click on the [Me] area in the lower right corner and select [three horizontal lines] in the upper right corner; 2. Then on the right The function bar will expand, slide the page to select [Settings] at the bottom; 3. Then on the settings function page, find the [Personal Information Management] service; 4. Finally jump to the personal information management page, slide [Personalized Content Recommendations] 】The buttons on the back can be set.

How to set the countdown to grab tickets in Damai How to set the countdown to grab tickets in Damai Apr 01, 2024 pm 07:01 PM

When buying tickets on Damai.com, in order to ensure that the ticket purchase time can be accurately grasped, users can set a floating clock to grab tickets. The detailed setting method is below, let us learn together. How to bind the floating clock to Damai 1. Click to open the floating clock app on your phone to enter the interface, and click on the location where the flash sale check is set, as shown in the figure below: 2. After coming to the page of adding new records, click on Damai.com Copy the ticket purchase link page copied in. 3. Next, set the flash sale time and notification time below, turn on the switch button behind [Save to Calendar], and click [Save] below. 4. Click to turn on [Countdown], as shown in the figure below: 5. When the reminder time comes, click the [Start Picture-in-Picture] button below. 6. When the ticket purchase time comes

Detailed method to set the mouse arrow to automatically hide in PPT Detailed method to set the mouse arrow to automatically hide in PPT Mar 26, 2024 pm 02:46 PM

1. Open PPT. 2. Click the play button in the lower left corner. 3. After entering the playback interface, click the right button of the mouse and then click the pointer option. 4. Then click the arrow option. 5. Three options appear, namely automatic, visible, and always hidden. Among them, automatic means that the mouse will be automatically hidden if it does not move for three seconds, visible means that the mouse will remain displayed, and always hidden means that the mouse will be hidden forever. 6. Select the desired display method and click OK. Note: The setting is only valid for this slide show. The automatic mode will be defaulted to when other slides are opened.

See all articles