Contents
apache2( httpd-2.4.39 )のインストールとバーチャルホスト設定
1.apache2インストール
①httpd-2.4.39 をダウンロード
# wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
# wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
# tar zxvf apr-1.6.3.tar.gz
# tar zxvf apr-util-1.6.1.tar.gz
# mv apr-1.6.3 httpd-2.4.39/srclib/apr
# mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
# tar xvfz expat-2.2.7.tar.gz
# cd expat-2.2.7
# ./configure –prefix=/usr/local/expat/2_2_7
# make
# make install
インストールされたライブラリを”/usr/local”配下にシンボリックリンクで作成します
# ln -s /usr/local/expat/2_2_7/bin/xmlwf /usr/local/bin/
※ /usr/local/include
# ln -s /usr/local/expat/2_2_7/include/expat.h /usr/local/include/
ln -s /usr/local/expat/2_2_7/include/expat_config.h /usr/local/include/
ln -s /usr/local/expat/2_2_7/include/expat_external.h /usr/local/include/
※ /usr/local/lib
# ln -s /usr/local/expat/2_2_7/lib/libexpat.a /usr/local/lib/
ln -s /usr/local/expat/2_2_7/lib/libexpat.la /usr/local/lib/
ln -s /usr/local/expat/2_2_7/lib/libexpat.so /usr/local/lib/
ln -s /usr/local/expat/2_2_7/lib/libexpat.so.1 /usr/local/lib/
ln -s /usr/local/expat/2_2_7/lib/libexpat.so.1.6.9 /usr/local/lib/
# wget https://ja.osdn.net/projects/sfnet_pcre/downloads/pcre/8.45/pcre-8.45.tar.gz
# tar xvfz pcre-8.45.tar.gz
# cd pcre-8.45
# ./configure –prefix=/usr/local/pcre/8_45 –enable-jit
# make
# make install
インストールされたライブラリを”/usr/local”配下にシンボリックリンクで作成します
# ln -s /usr/local/pcre/8_45/bin/pcre-config /usr/local/bin/
ln -s /usr/local/pcre/8_45/bin/pcregrep /usr/local/bin/
ln -s /usr/local/pcre/8_45/bin/pcretest /usr/local/bin/
※ /usr/local/include
# ln -s /usr/local/pcre/8_45/include/pcre.h /usr/local/include/
ln -s /usr/local/pcre/8_45/include/pcre_scanner.h /usr/local/include/
ln -s /usr/local/pcre/8_45/include/pcre_stringpiece.h /usr/local/include/
ln -s /usr/local/pcre/8_45/include/pcrecpp.h /usr/local/include/
ln -s /usr/local/pcre/8_45/include/pcrecpparg.h /usr/local/include/
ln -s /usr/local/pcre/8_45/include/pcreposix.h /usr/local/include/
※ /usr/local/lib
# ln -s /usr/local/pcre/8_45/lib/libpcre.a /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcre.la /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcre.so /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcre.so.1 /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcre.so.1.2.11 /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcrecpp.a /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcrecpp.la /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcrecpp.so /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcrecpp.so.0 /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcrecpp.so.0.0.1 /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcreposix.a /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcreposix.la /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcreposix.so /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcreposix.so.0 /usr/local/lib/
ln -s /usr/local/pcre/8_45/lib/libpcreposix.so.0.0.6 /usr/local/lib/
# ./configure \
–with-layout=Apache \
–enable-module=auth_db \
–enable-module=so \
–enable-module=most \
–enable-mods-shared=reallyall \
–enable-rewrite \
–enable-auth_digest
# make
# make install
2.Apache の設定
# vi /usr/local/apache2/conf/httpd.conf
●83 行目あたり digest 認証を有効にします
「LoadModule auth_digest_module modules/mod_auth_digest.so」の行頭にある「#」を削除
●170 行目あたり CGI モジュールを有効化
「LoadModule cgid_module modules/mod_cgid.so」の行頭にある「#」を削除
●228 行目あたり ServerName の変更
「#ServerName www.example.com:80」の下に「ServerName ホスト名」を追加
●251 行目あたり ドキュメントルートの変更
「DocumentRoot “/usr/local/apache2/htdocs”」の行頭に「#」を入力してコメントアウト
●279 行目あたりに下記追加
<VirtualHost *:80>
ServerAdmin <管理者メールアドレス>
DocumentRoot /var/www/html/<わかりやすくドメイン名>/
ServerName <ドメイン名>
ErrorLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/<ドメイン名>_error_log_%Y%m%d 86400 540”
CustomLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/<ドメイン名>_access_log_%Y%m%d 86400 540” combined
ErrorDocument 404 /
</VirtualHost>
<Directory “/var/www/html/<ドメイン名>”>
Options Indexes Includes FollowSymLinks MultiViews ExecCGI
Require all granted
Allow from all
AddHandler server-parsed .html
</Directory>
●298 行目あたり index ファイルの追加
「index.htm index.php」を追加する
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
●316 行目あたり error_log 出力ディレクトリの変更
「ErrorLog “logs/error_log”」の行頭に「#」を追加し、その下に「ErrorLog “/var/log/httpd/error_log”」を追加します
#ErrorLog “logs/error_log”
ErrorLog “/var/log/httpd/error_log”
●345 行目あたり ログ設定をコメントアウト
#CustomLog “logs/access_log” common
●445 行目あたり
「AddHandler cgi-script .cgi」の先頭にある「#」を削除
●532 行目あたり httpd-default.conf を有効
「Include conf/extra/httpd-default.conf」の行頭にある「#」を削除
●10 行目あたり タイムアウト時間を変更
Timeout 300
# mkdir /var/log/httpd
# chmod 755 /var/www/html/<ドメイン名>/
# vi httpd.service
After=network.target remote-fs.target nss-lookup.target [Service] Type = forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecStop=/usr/local/apache2/bin/apachectl stop
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true [Install] WantedBy=multi-user.target
⑥Apache の自動起動設定と起動
Created symlink from /etc/systemd/system/multi -user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
# systemctl start httpd.service
firewallでポート開放
# firewall-cmd –permanent –add-service=https
# firewall-cmd –reload
Index of / と表示されればOK
PHP( PHP-7.3.6 )のインストールと設定
1.事前準備
PHP のインストールに必要なソフトウェアをインストール
# dnf -y install libjpeg-turbo-devel
# dnf -y install libpng-devel
# dnf -y install freetype freetype-devel
# dnf -y install libcurl-devel
2.PHPインストール
# wget https://www.php.net/distributions/php-7.3.6.tar.gz
(# wget –no-check-certificate https://www.php.net/distributions/php-7.3.6.tar.gz)
# tar zxvf php-7.3.6.tar.gz
# cd php-7.3.6
# ./configure \
–prefix=/usr/local/php7 \
–with-config-file-path=/usr/local/php7/etc \
–with-apxs2=/usr/local/apache2/bin/apxs \
–enable-mbstring \
–enable-mbregex \
–with-gd \
–enable-gd-jis-conv \
–with-freetype-dir=/usr \
–with-png-dir=/usr \
–with-zlib \
–with-jpeg-dir=/usr \
–with-mysqli=mysqlnd \
–with-mysql-sock=/var/lib/mysql/mysql.sock \
–with-curl
# make
# make install
●188 行目あたり
「LoadModule php7_module modules/libphp7.so」の下の行に
「AddType application/x-httpd-php .php」を追加
# vi /usr/local/php7/etc/php.ini
●401 行目あたり
「memory_limit = 128M」をmemory_limit = 512Mに変更
●474 行目あたり
「display_errors = On」を「display_errors = Off」に変更
●686 行目あたり
「post_max_size = 8M」を「post_max_size = 128M」に変更
●838 行目あたり
「upload_max_filesize = 2M」を「upload_max_filesize = 2000M」に変更
●940 行目あたり
「extension=curl.so」と「extension=openssl.so」を追加
;extension=xsl
extension=curl.so
extension=openssl.so
●954 行目あたり
「date.timezone = Asia/Tokyo」を追加
;date.timezone =
date.timezone = Asia/Tokyo
# /usr/local/php7/bin/phpize
# ./configure –with-curl -with-php-config=/usr/local/php7/bin/php-config
# make
# make install
# ls -l /usr/local/php7/lib/php/extensions/no-debug-zts-20180731/
合計3356
-rwxr-xr-x 1 root root 517720 Feb 3 19:49 curl.so
-rwxr-xr-x 1 root root 2913912 Feb 3 19:42 opcache.so
下記のファイルを作成
<?php phpinfo(); ?>