Apache/ko

"아파치 HTTP 서버"는 효율적이고 확장성있는 웹 서버이며 인터넷에서 가장 널리 사용하는 프로그램중 하나입니다.

다른 패키지에서의 지원
다른 패키지에서 아파치에 대한 지원을 활성화 하도록 하는 전역 USE 플래그 "apache2"가 있습니다. 어떤 패키지가 아파치를 활용한다면 자동으로 를 끌어오도록 합니다.

플래그를 설정하고 나서 바뀐 내용을 적용하려면 다음 명령을 실행하십시오:

OpenRC
아파치 서버를 시작하십시오:

기본 런레벨에 아파치를 추가하십시오:

아파치 서비스를 재시작하십시오:

아파치 설정 파일을 다시 읽으십시오:

systemd
아파치 서버를 시작하십시오:

아파치를 기본 런레벨에 추가하십시오

아파치 서비스를 다시 시작하십시오:

시험
아파치2가 어떤 IP 인터페이스에서 실행하고 어떤 포트 상에서 감청중인지 검증하십시오:

Testing if a connection to a Apache server is working on localhost:

Interrupt the connection test with + and.

Configuration files
There are 2 main files that configure Apache2's behavior on the system:


 * Gentoo's apache2 init script configuration file


 * Apache server's conventional configuration file

Gentoo's init script configuration file
The only active line in this file is as follow :

This line defines options that will be interpreted by the various configuration files using the   statement to activate or deactivate some part of the whole configuration. We will come back to this where appropriate in the rest of this guide.

Apache server's conventional configuration file - httpd.conf
In fact this file is only an entry point as the whole configuration is split in many files in the directory, that are assembled  together using the   directive. For example, the statement, in , aims at including all the files in  which name ends with.

Taking into account what has been said in the subsection above, and as module configuration files (files in /etc/apache2/modules.d) almost always start with the, the content of one file inside , will ONLY be assembled with the rest of the configuration, if the matching option is set using a   flag in the APACHE2_OPTS variable in the  file. The configuration file is an exception to this rule as it doesn't start with an   statement and therefore is always included in the resulting configuration.

Default configuration
After a fresh install of apache server, the configuration resulting from the assemblage of the different configuration files is as follows. We start with the entry point.

First sign of life
As you can see in the initial configuration above, the pre-installed virtual host's    directory is, its server name is localhost. In addition an index.html file is provided in the  directory, thus to check whether everything is correctly installed or not, point your browser to http://www.localhost.

You should see an "It works !" message on the page.

Enabling Security Module
Control this module by editing and  and restarting apache.

Enabling PHP support
Install PHP with the apache2 USE flag and enable the module:

To test if the PHP module works, create a test page:

Now open the test page: http://localhost/. You should see a table describing the PHP settings

Adding your own virtual hosts
For each virtual host, provide a  directory that is reachable and accessible by the Apache daemon. Add a virtual host configuration file in the  directory which uses this   and the virtual host server name, and don't forget to add an entry for this domain name in.

To assign the apache user/group ownership on the virtual host files, use  like in the following example:

Below are two example virtual host definitions, one for domainname1.com and one for domainname2.com. Notice the different  and   directives even though the host itself  remains the same:

Example virtual host definitions

It is recommended to provide an IP based virtual host definition as well. This allows the administrator to put up a message for users that try to reach a site through its IP address:

IP-based virtual host

After inserting virtual hosts, the server needs to be (gracefully) restarted for the new sites to become active.

Enabling PHP through fcgid
Install and. The PHP package requires the cgi USE flag:

Edit the file:

Create the needed directory:

Symlink it for the PHP wrapper:

Enable the fcgid module:

Finally restart Apache and check the  site created earlier. The value of  should be CGI/FastCGI

Troubleshooting

 * Troubleshooting guide

Common Issues
When starting apache, you might get the following error:

apache2: apr_sockaddr_info_get failed for SomeHostname

When this occurs, add your host name to the file.

External resources

 * Slicehost article: Installing Apache on Gentoo
 * Slicehost article: Apache configuration files on Gentoo
 * Slicehost article: Configuring the Apache MPM on Gentoo
 * Slicehost article: Apache configuration on Gentoo
 * Slicehost article: Apache Virtual Hosts on Gentoo
 * Slicehost article: Enabling and using apache's mod_status on Gentoo
 * apache.org documentation
 * Apache2 mod_pagespeed