Apache服务器配置全攻略(三)_PHP
Apache
主服务器设置Apache服务器需要各种设置,以定义自己使用各种参数以提供Web服务。对于使用虚拟主机的情况,除了在虚拟主机的定义项中覆盖的设置之外(有的设置必须重新定义),这里的设置也是虚拟主机的缺省设置。
Port 80
Port定义了Standalone模式下httpd守护进程使用的端口,标准端口是80。这个选项只对于以独立方式启动的服务器才有效,对于以inetd方式启动的服务器则在inetd.conf中定义使用哪个端口。
在Unix下使用80端口需要root权限,一些管理员为了安全的原因,认为 httpd 服务器不可能没有安全漏洞,因而更愿意使用普通用户的权限来启动服务器,这样就不能使用80端口及其他小于1024的端口,而必须使用大于 1024的端口来启动httpd,一般情况下8000或8080也是常用的端口。而Apache httpd服务器本身可以在以root权限打开80端口后再改变为普通用户身份进行运行,这样就减少了危险性,因而就不需要考虑这个安全问题。但是如果普通用户也想安装配置自己的WWW服务器,那么就不得不使用大于1024的端口。
User nobody
Group nogroup
User和Group配置是Apache的安全保证,Apache在打开端口之后,就将其本身设置为这两个选项设置的用户和组权限进行运行,这样就降低了服务器的危险性。这个选项也只用于 Standalone模式,inetd模式在inetd.conf中指定运行Apache的用户。由于服务器必须执行改变身份的setuid()操作,因此初始进程应该具备root权限,如果是使用非root用户来启动Aapche,这个配置就不会发挥作用。
缺省设置为nobody和nogroup,这个用户和组在系统中不拥有文件,保证了服务器本身和由它启动的CGI 进程没有权限更改文件系统。在某些情况下,例如为了运行CGI与Unix交互,也需要让服务器来访问服务器上的文件,如果仍然使用nobody和nogroup,那么系统中将会出现属于nobody的文件,这对于系统安全是不利的,因为其他程序也会以nobody和nogroup的权限执行某些操作,就有可能访问这些nobody拥有的文件,造成安全问题。一般情况下要为Web服务设定一个特定的用户和组,同时在这里更改用户和组设置。
ServerAdmin you@your.address
配置文件中应该改变的也许只有ServerAdmin, 这一项用于配置WWW服务器的管理员的email地址,这将在HTTP服务出现错误的条件下返回给浏览器,以便让Web使用者和管理员联系,报告错误。习惯上使用服务器上的webmaster作为WWW服务器的管理员,通过邮件服务器的别名机制,将发送到webmaster 的电子邮件发送给真正的Web管理员。
#ServerName new.host.name
缺省情况下,并不需要指定这个ServerName参数,服务器将自动通过名字解
析过程来获得自己的名字,但如果服务器的名字解析有问题(通常为反向解析不
正确),或者没有正式的DNS名字,也可以在这里指定IP地址。当ServerName设
置不正确的时候,服务器不能正常启动。
通常一个Web服务器可以具有多个名字,客户浏览器可以使用所有这些名字或IP地址来访问这台服务器,但在没有定义虚拟主机的情况下,服务器总是以自己的正式名字回应浏览器。ServerName就定义了Web服务器自己承认的正式名字,例如一台服务器名字(在DNS中定义了A类型)为exmaple.org.cn,同时为了方便记忆还定义了一个别名(CNAME记录)为www.exmaple.org.cn,那么Apache自动解析得到的名字就为example.org.cn,这样不管客户浏览器使用哪个名字发送请求,服务器总是告诉客户程序自己为 example.org.cn。虽然这一般并不会造成什么问题,但是考虑到某一天服务器可能迁移到其他计算机上,而只想通过更改DNS中的www别名配置就完成迁移任务,所以不想让客户在其书签中使用 Linux 记录下这个服务器的地址,就必须使用ServerName来重新指定服务器的正式名字。
DocumentRoot "/www/"
DocumentRoot定义这个服务器对外发布的超文本文档存放的路径,客户程序请求的UR L就被映射为这个目录下的网页文件。这个目录下的子目录,以及使用
符号连接指出的文件和目录都能被浏览器访问,只是要在URL上使用同样的相对目录名。
注意,符号连接虽然逻辑上位于根文档目录之下,但实际上可以位于计算机
上的任意目录中,因此可以使客户程序能访问那些根文档目录之外的目录,这在
增加了灵活性的同时但减少了安全性。Apache在目录的访问控制中提供了FollowSymLinks选项来打开或关闭支持符号连接的特性。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

How to use the Little Black Box cdkey? To put it simply, you can directly purchase games on the Steam platform from the Little Black Box, and you will receive a CDK redemption code after successful purchase. Next, use this redemption code in the Steam Mall to purchase the corresponding game. Many friends may not know how to use the small black box cdkey. Below I will explain the redemption steps in detail. I hope it will be helpful to you. How to use the Little Black Box cdkey 1. First copy the CDK redemption code obtained after purchasing the Little Black Box game. 2. Then start the Steam platform. 3. Click on the "Game" option in the menu in the upper left corner. 4. Find and click "Activate Product on Steam" in the new menu. 5. Click Next directly on the pop-up interface. 6. Purchase the small black box
