apacheの初期設定を実施します。
とりあえずパラメータはほとんどデフォルトでいきます。必要だったら後から変更します。
目次
httpd.confの修正
まずはhttpd.confを修正します。ログはvhostとlocalで分けます。
変更した箇所はdiffで表示しますので、必要であれば該当箇所を修正して下さい。
# cd /usr/local/apache2 # mkdir -p logs/`hostname` # mkdir -p logs/test.unknownengineer.net # cd conf # cp -p httpd.conf httpd.conf.`date +"%Y%m%d"` # vim httpd.conf # diff -u httpd.conf.`date +"%Y%m%d"` httpd.conf --- httpd.conf.20171108 2017-10-30 17:06:54.051143424 +0900 +++ httpd.conf 2017-11-08 16:29:12.041329971 +0900 @@ -49,7 +49,7 @@ # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 -Listen 80 +Listen 192.168.0.*:80 # # Dynamic Shared Object (DSO) Support @@ -148,7 +148,7 @@ #LoadModule speling_module modules/mod_speling.so #LoadModule userdir_module modules/mod_userdir.so LoadModule alias_module modules/mod_alias.so -#LoadModule rewrite_module modules/mod_rewrite.so +LoadModule rewrite_module modules/mod_rewrite.so <IfModule unixd_module> # @@ -159,8 +159,8 @@ # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # -User daemon -Group daemon +User apache +Group apache </IfModule> @@ -181,7 +181,7 @@ # e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@your-domain.com # -ServerAdmin you@example.com +ServerAdmin *@gmail.com # # ServerName gives the name and port that the server uses to identify itself. @@ -190,7 +190,7 @@ # # If your host doesn't have a registered DNS name, enter its IP address here. # -#ServerName www.example.com:80 +ServerName web1.unknownengineer.local:80 # # Deny access to the entirety of your server's filesystem. You must @@ -266,7 +266,7 @@ # 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 "logs/error_log" +ErrorLog "logs/web1.unknownengineer.local/error_log" # # LogLevel: Control the number of messages logged to the error_log. @@ -295,7 +295,7 @@ # define per-<VirtualHost> access logfiles, transactions will be # logged therein and *not* in this file. # - CustomLog "logs/access_log" common + CustomLog "logs/web1.unknownengineer.local/access_log" common # # If you prefer a logfile with access, agent, and referer information @@ -455,7 +455,7 @@ # necessary. # Server-pool management (MPM specific) -#Include conf/extra/httpd-mpm.conf +Include conf/extra/httpd-mpm.conf # Multi-language error messages #Include conf/extra/httpd-multilang-errordoc.conf @@ -464,7 +464,7 @@ #Include conf/extra/httpd-autoindex.conf # Language settings -#Include conf/extra/httpd-languages.conf +Include conf/extra/httpd-languages.conf # User home directories #Include conf/extra/httpd-userdir.conf @@ -473,7 +473,7 @@ #Include conf/extra/httpd-info.conf # Virtual hosts -#Include conf/extra/httpd-vhosts.conf +Include conf/extra/httpd-vhosts.conf # Local access to the Apache HTTP Server Manual #Include conf/extra/httpd-manual.conf @@ -482,7 +482,7 @@ #Include conf/extra/httpd-dav.conf # Various default settings -#Include conf/extra/httpd-default.conf +Include conf/extra/httpd-default.conf # Configure mod_proxy_html to understand HTML4/XHTML1 <IfModule proxy_html_module>
extraディレクトリ以下のファイル修正
こちらも同様に必要な箇所を修正します。
# cd extra # cp -p httpd-default.conf httpd-default.conf.`%Y%m%d` # cp -p httpd-default.conf httpd-default.conf.`date +"%Y%m%d"` # cp -p httpd-vhosts.conf httpd-vhosts.conf.`date +"%Y%m%d"` # cp -p httpd-languages.conf httpd-languages.conf.`date +"%Y%m%d"` # vim httpd-default.conf # diff -u httpd-default.conf.`date +"%Y%m%d"` httpd-default.conf --- httpd-default.conf.20171108 2017-11-08 16:43:16.417532885 +0900 +++ httpd-default.conf 2017-11-08 16:22:32.709300270 +0900 @@ -13,7 +13,7 @@ # KeepAlive: Whether or not to allow persistent connections (more than # one request per connection). Set to "Off" to deactivate. # -KeepAlive On +KeepAlive Off # # MaxKeepAliveRequests: The maximum number of requests to allow @@ -52,7 +52,7 @@ # Set to one of: Full | OS | Minor | Minimal | Major | Prod # where Full conveys the most information, and Prod the least. # -ServerTokens Full +ServerTokens Prod # # Optionally add a line containing the server version and virtual host # vim httpd-languages.conf # diff -u httpd-languages.conf.`date +"%Y%m%d"` httpd-languages.conf --- httpd-languages.conf.20171108 2017-11-08 16:27:38.357977512 +0900 +++ httpd-languages.conf 2017-11-08 16:28:06.190676412 +0900 @@ -75,14 +75,14 @@ # Just list the languages in decreasing order of preference. We have # more or less alphabetized them here. You probably want to change this. # -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 tr zh-CN 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 tr zh-CN zh-TW # # ForceLanguagePriority allows you to serve a result page rather than # MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback) # [in case no accepted languages matched the available variants] # -ForceLanguagePriority Prefer Fallback +#ForceLanguagePriority Prefer Fallback # # Commonly used filename extensions to character sets. You probably # vim httpd-vhosts.conf # diff -u httpd-vhosts.conf.`date +"%Y%m%d"` httpd-vhosts.conf --- httpd-vhosts.conf.20171108 2017-10-30 17:06:54.617157624 +0900 +++ httpd-vhosts.conf 2017-11-08 16:26:16.703927039 +0900 @@ -20,22 +20,10 @@ # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # -<VirtualHost *:80> - ServerAdmin webmaster@dummy-host.example.com - DocumentRoot "/usr/local/apache-2.4.29/docs/dummy-host.example.com" - ServerName dummy-host.example.com - ServerAlias www.dummy-host.example.com - ErrorLog "logs/dummy-host.example.com-error_log" - CustomLog "logs/dummy-host.example.com-access_log" common +<VirtualHost 192.168.0.*:80> + ServerAdmin *@gmail.com + DocumentRoot "/mnt/nfs/test.unknownengineer.net/htdocs/" + ServerName test.unknownengineer.net + ErrorLog "logs/test.unknownengineer.net/error_log" + CustomLog "logs/test.unknownengineer.net/access_log" common </VirtualHost> - -<VirtualHost *:80> - ServerAdmin webmaster@dummy-host2.example.com - DocumentRoot "/usr/local/apache-2.4.29/docs/dummy-host2.example.com" - ServerName dummy-host2.example.com - ErrorLog "logs/dummy-host2.example.com-error_log" - CustomLog "logs/dummy-host2.example.com-access_log" common -</VirtualHost> - - - # ../../bin/httpd -t Syntax OK
たぶん起動だけはします。
systemdに登録
# vim /etc/systemd/system/httpd.service [Unit] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/apache2/bin/apachectl -k start ExecReload=/usr/local/apache2/bin/apachectl -k graceful ExecStop=/usr/local/apache2/bin/apachectl -k stop PrivateTmp=true [Install] WantedBy=multi-user.target # systemctl start httpd
起動してエラーが無ければ初回起動までは完了です。