Apache

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Apache and the translation is 79% complete.
Outdated translations are marked like this.

"아파치 HTTP 서버"는 효율적이고 확장성있는 웹 서버이며 인터넷에서 가장 인기있는 웹 서버 중 하나입니다.

설치

참고
아파치 버전 업데이트만이 목적이라면, 업그레이드 안내서를 확인하십시오.

USE 플래그

USE flags for www-servers/apache The Apache Web Server

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gdbm Add support for sys-libs/gdbm (GNU database libraries)
ldap Add LDAP support (Lightweight Directory Access Protocol)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
split-usr Enable behavior to support maintaining /bin, /lib*, /sbin and /usr/sbin separately from /usr/bin and /usr/lib*
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
static Link in apache2 modules statically rather then plugins
suexec Install suexec with apache
suexec-caps Install suexec with capabilities instead of SUID
suexec-syslog Log suexec to syslog instead of to a separate file
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
threads Add threads support for various packages. Usually pthreads

Emerge

Multi-Processing Module

To use the Apache event or worker MPM, enable the Apache threads USE flag:

파일 /etc/portage/package.useApache threads support
www-servers/apache threads

Apache event MPM을 활용하려면 make.conf에 다음 줄을 추가하십시오:

파일 /etc/portage/make.confApache event MPM
APACHE2_MPMS="event"
파일 /etc/portage/make.confApache event MPM
APACHE2_MPMS="event"

Apache worker MPM을 활용하려면 make.conf에 다음 줄을 추가하십시오:

파일 /etc/portage/make.confApache worker MPM
APACHE2_MPMS="worker"
파일 /etc/portage/make.confApache worker MPM
APACHE2_MPMS="worker"

If no Multi-Processing Module (MPM) is selected, the default MPM is used. The default MPM depends on platform capabilities (like threads support), read more in the official Apache docs.

그 다음 Apache를 이머지 하십시오:

root #emerge --ask www-servers/apache
root #emerge --ask www-servers/apache

전역 지원

apache2 전역 USE 플래그를 활성화 하면 다른 패키지에 아파치 기능을 지원합니다. 이 USE 플래그는 아파치에 의존성이 걸려있는 프로그램을 이머지할 때 www-servers/apache를 자동으로 설치합니다.

파일 /etc/portage/make.confAdding Apache to system USE flags
USE="apache2"

USE 변수를 설정한 후, 시스템을 업데이트하여 바뀐 설정을 적용하십시오.

root #emerge --ask --changed-use --deep @world

설정

파일

시스템에서 동작하는 아파치는 두가지 주요 파일에서 설정합니다:

  • 젠투 apache2 초기화 스크립트 설정 파일� /etc/conf.d/apache2
  • apache2 서버 기존 설정 파일 /etc/apache2/httpd.conf����

/etc/conf.d/apache2

/etc/conf.d 위치에 있는 apache2 파일은 젠투 init 스크립트 설정 파일입니다. 이 파일에서 유일한 활성 행은 APACHE2_OPTS 변수 부분입니다:

파일 /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE"

이 줄에서는 전체 설정중 일부를 활성화 하거나 비활성화 하는 <IfDefine option-name> 구문을 사용하여 다양한 설정 파일을 해석합니다. 나중에 이 게시글에서 다시 다루도록 하겠습니다.

아파치 서버의 기존 설정 파일 - httpd.conf

httpd.conf 파일은 아파치 서버의 기본 설정 파일입니다. 사실 이 파일은 설정의 항목 포인트일 뿐입니다. 전체 설정은 /etc/apache2/ 디렉터리의 여러 파일로 나누어져있으며, Include 지시어로 합쳐집니다. 예를 들어 httpd.confInclude /etc/apache2/modules.d/*.conf 구문은 /etc/apache2/modules.d/에서 .conf로 끝나는 모든 파일을 대상으로 합니다.

위의 하위 섹션에서 언급한 내용을 고려하여, 모듈 설정 파일(/etc/apache2/modules.d의 파일)이 거의 항상 <IfDefine module-name>로 시작하므로, 일치하는 옵션을 /etc/conf.d/apache2 파일의 APACHE2_OPTS 변수에서 -D module-name 플래그를 사용하여 설정하면 /etc/apache2/modules.d에 들어있는 파일 하나의 내용은 설정한 부분끼리만 모입니다. 00_default_settings.conf 설정 파일은 IfDefine 구문으로 시작하지 못했을 때 이 규칙에 대한 예외로 존재하므로 결과 설정에 항상 포함됩니다.

기본 설정

아파치를 새로 설치한 다음의 설정은 다음과 같이 여러가지 설정 파일의 모음으로 이루어져 있습니다. /etc/apache2/httpd.conf의 항목 포인트에서 시작하도록 하겠습니다.

경고
간단한 참고로"만" 제공하며 전체적인 맥락을 보여드릴 뿐입니다. 설정의 전반적인 내용을 이해하려면 다양한 파일에 포함된 주석을 살펴볼 것을 강력히 권장합니다. 아파치 설정 내용을 깊게 이해하려면 아파치 메뉴얼을 참고하십시오.
파일 /etc/apache2/httpd.conf
ServerRoot "/usr/lib64/apache2"
  
#Module loaded unconditionally, assuming the USE flag is no unset in
# /etc/portage/make.conf or in /etc/portage/package.use
LoadModule actions_modulemodules/mod_actions.so
...
#other modules loaded that way : alias_module, auth_basic_module, authn_alias_module,
# authn_anon_module, authn_dbm_module, authn_default_module, authn_file_module, 
# authz_dbm_module, authz_default_module, authz_groupfile_module, authz_host_module, 
# authz_owner_module, authz_user_module, autoindex_module,  cgi_module,  cgid_module, 
# deflate_module, dir_module, env_module, expires_module, ext_filter_module, filter_module,
#  headers_module, include_module,  log_config_module, logio_module, mime_module,  
# mime_magic_module, negotiation_module, rewrite_module, setenvif_module, 
# speling_module,ssl_module, status_module, unique_id_module, usertrack_module, host_alias_module
  
  
#Modules loaded conditionally, assuming matching USE flag is not unset in
# /etc/portage/make.conf or in /etc/portage/package.use (flag to be set in )
<IfDefine AUTHNZ_LDAP>
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
</IfDefine>
#other modules loaded that way : cache_module, dav_module, dav_fs_module,
# dav_lock_module,disk_cache_module,  file_cache_module, info_module, ldap_module,
# mem_cache_module, userdir_module
  
  
User apache
Group apache
  
# Supplemental configuration
#**************************************************************************************vvv
#this part is included via Include /etc/apache2/modules.d/*.conf 
  
#included from /etc/apache2/modules.d/00_default_settings.conf-------------v
#this is always included as there is not option to deactivate it.
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
TraceEnable off
ServerSignature On 
HostnameLookups Off
EnableMMAP On
EnableSendfile On
FileEtag INode MTime Size
ContentDigest Off
ErrorLog /var/log/apache2/error_log
LogLevel warn
  
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>
  
<IfModule dir_module>
	DirectoryIndex index.html index.html.var
</IfModule>
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>
#--------------------------------------------------------------------------^
  
#included from 00_mod_info.conf--------------------------------------------v
<IfDefine INFO>
<Location /server-info>
	SetHandler server-info
	Require host 127.0.0.1
</Location>
</IfDefine>
#--------------------------------------------------------------------------^
  
#--------------------------------------------------------------------------v
#included from 00_languages.conf
# Settings for hosting different languages.
<IfDefine LANGUAGE>
  
	AddLanguage ca .ca
	...
	AddLanguage zh-TW .zh-tw
  
	LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
  
	ForceLanguagePriority Prefer Fallback
  
	AddCharset us-ascii.ascii	.us-ascii
	AddCharset ISO-8859-1		.iso8859-1 .latin1
	...
	AddCharset shift_jis		.shift_jis .sjis
</IfDefine>
#---------------------------------------------------------------------------^
#**************************************************************************************^^^
  
  
#***************************************************************************************vvv
#this part is included via Include /etc/apache2/vhosts.d/*.conf 
#from 00_default_ssl_vhost.conf-----------------------------------------------------vv
<IfDefine SSL>
	<IfDefine SSL_DEFAULT_VHOST>
		<IfModule ssl_module>
			Listen 443
  
			<VirtualHost _default_:443>
				ServerName localhost
                                #------------------------------------------v
				# this part is included via Include /etc/apache2/vhosts.d/default_vhost.include
				ServerAdmin root@localhost
				DocumentRoot "/var/www/localhost/htdocs"
  
  	
				<Directory "/var/www/localhost/htdocs">
	   				Options Indexes FollowSymLinks
	   				AllowOverride All
	   				Require all granted
				</Directory>
  
				<IfModule alias_module>
	   				ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"
				</IfModule>
  
				<Directory "/var/www/localhost/cgi-bin">
	   				AllowOverride None
	   				Options None
	   				Require all granted
				</Directory>
        			#end of Include ---------------------------^
  	
				ErrorLog /var/log/apache2/ssl_error_log
  
				<IfModule log_config_module>
					TransferLog /var/log/apache2/ssl_access_log
				</IfModule>
				SSLEngine on
				SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
				SSLCertificateFile /etc/ssl/apache2/server.crt
				SSLCertificateKeyFile /etc/ssl/apache2/server.key
  
				<FilesMatch "\.(cgi|shtml|phtml|php)$">
					SSLOptions +StdEnvVars
				</FilesMatch>
  
				<Directory "/var/www/localhost/cgi-bin">
					SSLOptions +StdEnvVars
				</Directory>
  
				<IfModule setenvif_module>
					BrowserMatch ".*MSIE.*" \
					nokeepalive ssl-unclean-shutdown \
					downgrade-1.0 force-response-1.0
				</IfModule>
  
  
				<IfModule log_config_module>
					CustomLog /var/log/apache2/ssl_request_log \
					"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
					</IfModule>
			</VirtualHost>
		</IfModule>
	</IfDefine>
</IfDefine>
#---------------------------------------------------------------------------------^^
#from 00_default_vhost.conf-------------------------------------------------------vv
<IfDefine DEFAULT_VHOST>
	Listen 80
	NameVirtualHost *:80
  
	<VirtualHost *:80>
		ServerName localhost
  
		#---------------------------------------------------------------v
		# this part is included via Include /etc/apache2/vhosts.d/default_vhost.include
		ServerAdmin root@localhost
		DocumentRoot "/var/www/localhost/htdocs"
  
  	
		<Directory "/var/www/localhost/htdocs">
	   		Options Indexes FollowSymLinks
	   		AllowOverride All
	   		Require all granted
		</Directory>
  
		<IfModule alias_module>
	   		ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"
		</IfModule>
  
		<Directory "/var/www/localhost/cgi-bin">
	   		AllowOverride None
	   		Options None
	   		Require all granted
		</Directory>
        	#end of Include -----------------------------------------------^
  
		<IfModule mpm_peruser_module>
			ServerEnvironment apache apache
		</IfModule>
	</VirtualHost>
</IfDefine>
#-----------------------------------------------------------------------------------^^
# end of include ****************************************************************************************^^^

첫 생존 신호

위의 초기 설정내용에서 보셨다시피 이미 설치한 가상 호스트의 DocumentRoot 디렉터리는 서버 이름을 localhost로 지정한 /var/www/localhost/htdocs입니다. index.html을 DocumentRoot에서 설정하므로 모든 요소를 올바르게 설치했는지 여부를 보려면 http://www.localhost를 열어보십시오.

페이지에 "It works !" 메시지가 나타나야 합니다.

경고
특별히, Firefox에서는 탐색 표시줄에 URL을 잘못 입력하는 사용자를 돕는 기능을 넣었습니다. URL 해석에 실패하면, 파이어폭스에서는 실제 의도했'을 수도 있는' URL의 .com을 뒤에 붙이거나 www. 을 앞에 붙이는 몇가지 대체 방안을 제시합니다.

파이어폭스 이전 버전에 도입한 이 기능은 개발자들에게 귀찮은 존재입니다. 이 기능은 그러니까 localhost에서 서버가 실행중일 경우 응답에 실패했을 때, 결국 localhost.com이나 www.localhost.com을 찾아봅니다. 이런 방법을 통해 종종 페이지 찾을 수 없는 문제를 해결합니다.

이 `기능`을 비활성화 하려면:

  1. about:config를 탐색 표시줄에 입력하십시오
  2. "고급 기능 사용 동의"를 클릭하고 특수 설정 페이지로 들어가십시오
  3. 검색 입력창에 browser.fixup.alternate.enabled를 입력하십시오
  4. 하단에 나타난 browser.fixup.alternate.enabled에서 마우스 오른쪽 버튼을 누르고, 값을 false로 설정하십시오.

mod_security 활성화

ModSecurity is a rule-based web application firewall that monitors web service traffic, to block attacks exploiting known vulnerabilities.

www-apache/mod_security를 설치하십시오:

root #emerge --ask www-apache/mod_security

apache2 파일의 APACHE2_OPTS 변수에 SECURITY 모듈을 활성화하십시오:

파일 /etc/conf.d/apache2Enabling the security module
APACHE2_OPTS="... -D SECURITY"

/etc/apache2/modules.d/79_modsecurity.conf/etc/apache2/modules.d/80_modsecurity-crs.conf 파일을 편집하여 모듈을 처리한 다음 아파치를 다시 시작하십시오.

PHP 지원 활성화

apache2 USE 플래그를 넣고 PHP를 설치한 다음 모듈을 활성화 하십시오:

파일 /etc/conf.d/apache2PHP 모듈 활성화
APACHE2_OPTS="... -D PHP"

PHP 모듈이 동작하는지 시험하기 전, /etc/apache2/modules.d/70_mod_php.conf 파일이 있는지, 다음 정의가 있는지 확인하십시오:

파일 /etc/apache2/modules.d/70_mod_php.conf불러올 PHP 모듈 확인
<IfDefine PHP>
	# The mod_php.so symlink is controlled by
	# eselect-php. However, the module name changed from
	# php5_module to php7_module so we can't blindly load whatever
	# is there. Instead we let eselect-php manage a small
	# configuration file that loads the appropriate module.
	#
	# This is relative to ServerRoot (see httpd.conf).
	Include ../../../var/lib/eselect-php/mod_php.conf
 
	# Tell apache that mod_php should handle PHP files.
	#
	# NOTE: Avoiding AddHandler/AddType for security (bug
	# #538822). Please read the related news item!
	<FilesMatch "\.(php|php[57]|phtml)$">
		SetHandler application/x-httpd-php
	</FilesMatch>
 
	# PHP source files which are meant to be displayed as
	# syntax-highlighted source code.
	<FilesMatch "\.phps$">
		SetHandler application/x-httpd-php-source
	</FilesMatch>
 
	DirectoryIndex index.php index.phtml
</IfDefine>

내용이 없으면 직접 입력하십시오.

PHP 모듈이 잘 동작하는지 확인하려면, 테스트 페이지를 만드십시오:

파일 /var/www/localhost/htdocs/index.phpPHP test page
<html>
 <body>
  <?php phpinfo(); ?>
 </body>
</html>

이제 /var/www/localhost/htdocs/index.html를 숨기든지 이름을 바꾸시고 http://localhost/ 테스트 페이지를 여십시오.

표에서는 나타내고자 하는 PHP 설정을 보여줍니다.

= PHP 버전 수정

아파치에서 다루는 PHP 버전을 바꾸려면, 우선 apache2 서버 애플리케이션 프로그래밍 인터페이스(SAPI) 목록에서 존재하는 버전을 확인하십시오:

root #eselect php list apache2
 [1]   php5.3
 [2]   php5.4 *
 [3]   php5.5

선택할 버전으로 바꾸십시오:

root #eselect php set apache2 N

위 예제에서 N을 앞서 보여드린 eselect php list apache2 요청 출력 결과에 나타난 숫자 값으로 바꾸십시오.

가상 호스트

각각의 가상 호스트에 아파치 데몬에서 도달 및 접근 가능한 DocumentRoot 디렉터리를 제공하십시오. 이 DocumentRoot 와 가상 호스트 서버 이름을 제공하는 /etc/apache2/vhosts.d 디렉터리의 가상 호스트 파일(VirtualHost.conf)을 추가하십시오. /etc/hosts 파일에 이 도메인 이름에 대한 항목을 추가하는 것을 잊지 마십시오.

아파치 가상 호스트 파일에 사용자/그룹 소유 권한을 할당하려면 다음과 같이 chown 명령을 활용하십시오:

root #chown apache:apache /var/www/sitename

아래 두가지 가상 호스트 정의 예제에서 하나는 domainname1.com, 다른 하나는 domainname2.com에 대한 정의입니다. 호스트 부분(*:80)은 같게 내버려 두지만, DocumentRootServerName 지시자의 값은 다름을 눈여겨 보십시오:

코드 가상 호스트 정의 예제
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/website1
    ServerName domainname1.com
</VirtualHost>
  
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/website2
    ServerName domainname2.com
</VirtualHost>

이와 같이 IP 기반 가상 호스트 정의를 제공하는 것도 추천합니다. IP 주소를 통해 사이트에 접근하려는 사용자에게 관리자가 메시지를 뿌릴 수 있게 합니다.

코드 IP-기반 가상 호스트
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/html
    ServerName xxx.xxx.xxx.xxx
</VirtualHost>

가상 호스트를 넣은 다음, 서버는 새 사이트를 활성화 하기 위해 (적절하게) 재시작해야 합니다.

fcgid를 통한 PHP 활성화

www-apache/mod_fcgiddev-lang/php를 설치하십시오. PHP 패키지에 cgi USE 플래그를 넣어야 합니다:

root #emerge --ask www-apache/mod_fcgid dev-lang/php

mod_fcgid.conf 파일을 편집하십시오:

파일 /etc/apache2/modules.d/20_mod_fcgid.conf
<IfDefine FCGID>
LoadModule fcgid_module modules/mod_fcgid.so
SocketPath /var/run/fcgidsock
SharememPath /var/run/fcgid_shm
  
AddHandler php-fcgid .php
AddType application/x-httpd-php .php
Action php-fcgid /fcgid-bin/php-fcgid-wrapper
# max request 128mb
FcgidMaxRequestLen 134217728
<Location /fcgid-bin/>
        SetHandler fcgid-script
        Options +ExecCGI
</Location>
</IfDefine>

필요한 디렉터리를 만드십시오:

root #mkdir /var/www/localhost/htdocs/fcgid-bin

PHP 래퍼에 대한 심볼릭 링크를 만드십시오:

root #ln -s /usr/bin/php-cgi /var/www/localhost/htdocs/fcgid-bin/php-fcgid-wrapper

FCGID 모듈을 활성화 하십시오:

파일 /etc/conf.d/apache2fcgid 모듈 활성화
APACHE2_OPTS="... -D FCGID"

마지막으로 아파치를 다시 시작하고 먼저 만든 페이지의 phpinfo() 사이트가 뜨는지 확인하십시오. Server API 값은 "CGI/FastCGI"여야 합니다.

아파치 2.4에서 mod_proxy_fcgi를 통한 PHP-FPM 활성화

mod_proxy_fcgi에서 PHP-FPM을 활성화하려면 다음 선결 조건을 만족해야합니다:

  • PHP 5.3 이상
  • Apache 2.4 이상

게다가 2.4 버전에서는 기능 동작에 몇가지 제한이 있습니다:

다음 설정은 2.4.10 이상에서만 동작합니다. FilesMatch 지시자에 의존하며 메인 서버 설정 또는 VirthalHosts 내에 위치합니다. 유닉스 소켓의 위치는 사이트 내지는 함수의 각각의 지정 풀을 허용하는 php-fpm.conf 설정 파일의 listen 지시어로 결정합니다.

다음 예제에서는 아파치의 PHP 모듈 설정 파일에 FilesMatch 설정을 둡니다.

파일 /etc/apache2/modules.d/70_mod_php.confPHP-FPM 사용(Apache 2.4.10 이상 버전에 추천)
<IfDefine PHP>
        <FilesMatch "\.php$">
                SetHandler "proxy:unix:/var/run/php-fpm/www.sock|fcgi://localhost"
        </FilesMatch>
  
	# Set it to handle the files
	<IfModule mod_mime.c>
		AddHandler application/x-httpd-php .php .php5 .phtml
		AddHandler application/x-httpd-php-source .phps
	</IfModule>
  
	DirectoryIndex index.php index.phtml
 </IfDefine>

또는 ProxPassMatch 지시문을 사용할 수 있습니다. 이 옵션은 아파치 버전 2.4.0부터 2.4.8까지에 해당하는 경우에만 사용할 수 있습니다.

파일 /etc/apache2/modules.d/70_mod_php.confPHP-FPM 사용(Apache 2.4.8 이전 버전에 추천)
<IfDefine PHP>
        # Send all requested PHP files to PHP-FPM via fcgi://PHP_FPM_LISTEN_ADDRESS:PHP_FPM_LISTEN_PORT/DOCUMENT_ROOT/$1
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/localhost/htdocs/$1
  
	# Set it to handle the files
	<IfModule mod_mime.c>
		AddHandler application/x-httpd-php .php .php5 .phtml
		AddHandler application/x-httpd-php-source .phps
	</IfModule>
  
	DirectoryIndex index.php index.phtml
 </IfDefine>

기본적으로 listen 지시어는 소켓에 설정하지 않습니다. 우선 소켓 파일을 저장할 디렉터리를 만드십시오:

root #mkdir /var/run/php-fpm

다음 내용에 따라 php-fpm.conf 파일을 업데이트하십시오:

파일 php-fpm.conf감청 설정 업데이트
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0666
listen.owner = nobody
listen.group = nobody
;listen.mode = 0666
 
 ; The address on which to accept FastCGI requests.
 ; Valid syntaxes are:
 ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
 ;                            a specific port;
 ;   'port'                 - to listen on a TCP socket to all addresses on a
 ;                            specific port;
 ;   '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
 ;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/www.sock

다음 PHP 모듈과 PROXY 모듈을 활성화하십시오:

파일 /etc/conf.d/apache2PHP 모듈과 PROXY 모듈 활성화
APACHE2_OPTS="... -D PHP -D PROXY"

Web frameworks and Apache

Some of the web frameworks that can work with Apache are covered on the wiki:

HTTPS with TLS certificates from Let’s Encrypt

It is important that any public-facing web server provide "secure" HTTPS access. Often, sites providing HTTPS will be configured to redirect HTTP requests to the HTTPS equivalent URL.

Let’s Encrypt is a not-for-profit certificate authority that issues free TLS certificates. certbot is a utility available in the Gentoo repository for easily requesting and installing TLS certificates, and automatically setting up HTTPS access for Apache.

See the Let's Encrypt article for information about using certbot. The EFF also have specific instructions on using certbot on Gentoo to configure Apache.

사용법

서비스

OpenRC

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

root #/etc/init.d/apache2 start

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

root #rc-update add apache2 default

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

root #/etc/init.d/apache2 restart

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

root #/etc/init.d/apache2 reload

systemd

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

root #systemctl start apache2

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

root #systemctl enable apache2

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

root #systemctl restart apache2

문제 해결

참고 자료

아파치 서버를 제대로 설정하기엔 어려울 수 있습니다. 아래 참고자료는 문제가 있을 경우 도움될 수 있습니다:

시험

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

root #netstat -tulpen | grep apache
tcp     0     0 0.0.0.0:80      0.0.0.0:*     LISTEN     0     10932720     4544/apache2        
tcp     0     0 0.0.0.0:443     0.0.0.0:*     LISTEN     0     10932716     4544/apache2        

로컬 호스트에서 아파치 서버 연결이 동작하는지 확인하십시오:

user $telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

연결 시험을 그만두려면 Ctrl+c 키와 Enter 키를 누르십시오.

apr_sockaddr_info_get() failed for <System_Hostname>

오류:

apache2: apr_sockaddr_info_get() failed for System_Hostname

해결책:

이 오류가 나타나면 /etc/hosts 파일에 호스트 이름을 추가하십시오:

파일 /etc/hostsAdding a Hostname for Apache
127.0.0.1 localhost System_Hostname

추가 참조

  • Lighttpd - 빠르고 가벼운 웹 서버입.
  • Nginx - 작고 견고한 리버스 프록시 지원 고성능 HTTP 서버

외부 자료