Contents
Installa apache2 and virtual host configuration
1.Install apache2
①Download 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
Create a symbolic link to the installed library under “/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
Create a symbolic link to the installed library under “/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/
# 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.Configure Apache
# vi /usr/local/apache2/conf/httpd.conf
●Per line 83 Enable digest authentication
「LoadModule auth_digest_module modules/mod_auth_digest.so」Remove the “#” from the beginning of the line
●Per line 170 Enable the CGI module.
「LoadModule cgid_module modules/mod_cgid.so」Remove the “#” from the beginning of the line
●Per line 228 Change ServerName
Add “ServerName [host name]” under “#ServerName www.example.com:80”.
●Per line 251 Change the document root
「DocumentRoot “/usr/local/apache2/htdocs”」Type “#” at the beginning of the line to comment it out
●Per line 279 Add the following
<VirtualHost *:80>
ServerAdmin <Administrator email address>
DocumentRoot /var/www/html/<Domain>/ ←I’m using the domain name for clarity.
ServerName <Domain>
ErrorLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/<Domain>_error_log_%Y%m%d 86400 540”
CustomLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/<Domain >_access_log_%Y%m%d 86400 540” combined
ErrorDocument 404 /
</VirtualHost>
<Directory “/var/www/html/<Domain>”>
Options Indexes Includes FollowSymLinks MultiViews ExecCGI
Require all granted
Allow from all
AddHandler server-parsed .html
</Directory>
●Per line298 Add an index file
Add “index.htm index.php”.
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
●Per line316 Change the error_log output directory
「ErrorLog “logs/error_log”」Add “#” at the beginning and add “ErrorLog “/var/log/httpd/error_log”” below it
#ErrorLog “logs/error_log”
ErrorLog “/var/log/httpd/error_log”
●Per line345 Comment out the log settings.
#CustomLog “logs/access_log” common
●Per line445
「AddHandler cgi-script .cgi」Remove the “#” from the beginning of the line
●Per line532 Enable httpd-default.conf
「Include conf/extra/httpd-default.conf」Remove the “#” from the beginning of the line
●Per line10 Change the timeout period.
Timeout 300
# mkdir /var/log/httpd
# chmod 755 /var/www/html/<Domain>/
# 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 Autostart Configuration and Startup
Created symlink from /etc/systemd/system/multi -user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
# systemctl start httpd.service
Open ports with firewalld
# firewall-cmd –permanent –add-service=https
# firewall-cmd –reload
If you see “Index of /”, it’s OK.
Installation and configuration of PHP ( PHP-7.3.6 )
1.advance preparation
Install the software needed to install PHP
# dnf -y install libjpeg-turbo-devel
# dnf -y install libpng-devel
# dnf -y install freetype freetype-devel
# dnf -y install libcurl-devel
2.Install 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
●Per line188
Add “AddType application/x-httpd-php .php” under “LoadModule php7_module modules/libphp7.so”.
# vi /usr/local/php7/etc/php.ini
●Per line401
Change “memory_limit = 128M” to “memory_limit = 512M”
●Per line474
Change “display_errors = On” to “display_errors = Off”.
●Per line686
Change “post_max_size = 8M” to “post_max_size = 128M”.
●Per line838
Change “upload_max_filesize = 2M” to “upload_max_filesize = 2000M”.
●Per 941
Add “extension=curl.so” and “extension=openssl.so”.
;extension=xsl
extension=curl.so
extension=openssl.so
●Per line954
Add “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/
total 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
Create the following file
<?php phpinfo(); ?>