Contents
1.Installation of Apache2 (httpd-2.4.39) and virtual host configuration
1-1.Apache2 installation
①Download and extract httpd-2.4.39
Download [root@Lepard ~]# cd /usr/local/src/ src]# wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz Extracting the Apache tar file src]# tar zxvf httpd-2.4.39.tar.gz |
➁Download and extract apr and apr-util
src]# wget https://archive.apache.org/dist/apr/apr-1.6.3.tar.gz src]# wget https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz src]# tar zxvf apr-1.6.3.tar.gz src]# tar zxvf apr-util-1.6.1.tar.gz src]# mv apr-1.6.3 httpd-2.4.39/srclib/apr src]# mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util |
➂Install expat-devel
src]# wget https://github.com/libexpat/libexpat/releases/download/R_2_2_7/expat-2.2.7.tar.gz src]# tar xvfz expat-2.2.7.tar.gz src]# cd expat-2.2.7 expat-2.2.7]# ./configure –prefix=/usr/local/expat/2_2_7 expat-2.2.7]# make expat-2.2.7]# make install |
④expatシンボリックリンクを作成
Create an expat symbolic link Create a symbolic link to the installed library under “/usr/local”. // /usr/local/bin expat-2.2.7]# ln -s /usr/local/expat/2_2_7/bin/xmlwf /usr/local/bin/ // /usr/local/include expat-2.2.7]# ln -s /usr/local/expat/2_2_7/include/expat.h /usr/local/include/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/include/expat_config.h /usr/local/include/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/include/expat_external.h /usr/local/include/ // /usr/local/lib expat-2.2.7]# ln -s /usr/local/expat/2_2_7/lib/libexpat.a /usr/local/lib/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/lib/libexpat.la /usr/local/lib/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/lib/libexpat.so /usr/local/lib/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/lib/libexpat.so.1 /usr/local/lib/ expat-2.2.7]# ln -s /usr/local/expat/2_2_7/lib/libexpat.so.1.6.9 /usr/local/lib/ |
⑤Installing PCRE
expat-2.2.7]# cd /usr/local/src src]# wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz src]# tar xvfz pcre-8.43.tar.gz src]# cd pcre-8.43 pcre-8.43]# ./configure –prefix=/usr/local/pcre/8_43 –enable-jit pcre-8.43]# make pcre-8.43]# make install |
⑥PCREライブラリーのシンボリックリンクを作成
Create a symbolic link to the installed library under “/usr/local”.
// /usr/local/bin pcre-8.43]# ln -s /usr/local/pcre/8_43/bin/pcre-config /usr/local/bin/ pcre-8.43]# ln -s /usr/local/pcre/8_43/bin/pcregrep /usr/local/bin/ pcre-8.43]# ln -s /usr/local/pcre/8_43/bin/pcretest /usr/local/bin/ // /usr/local/include pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcre.h /usr/local/include/ pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcre_scanner.h /usr/local/include/ pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcre_stringpiece.h /usr/local/include/ pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcrecpp.h /usr/local/include/ pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcrecpparg.h /usr/local/include/ pcre-8.43]# ln -s /usr/local/pcre/8_43/include/pcreposix.h /usr/local/include/ // /usr/local/lib pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcre.a /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcre.la /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcre.so /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcre.so.1 /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcre.so.1.2.11 /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcrecpp.a /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcrecpp.la /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcrecpp.so /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcrecpp.so.0 /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcrecpp.so.0.0.1 /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcreposix.a /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcreposix.la /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcreposix.so /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcreposix.so.0 /usr/local/lib/ pcre-8.43]# ln -s /usr/local/pcre/8_43/lib/libpcreposix.so.0.0.6 /usr/local/lib/ |
⑦ Install httpd-2.4.39
pcre-8.43]# cd httpd-2.4.39 httpd-2.4.39]# ./configure \ –with-layout=Apache \ –enable-module=auth_db \ –enable-module=so \ –enable-module=most \ –enable-mods-shared=reallyall \ –enable-rewrite \ –enable-auth_digest httpd-2.4.39]# make httpd-2.4.39]# make install |
1-2.Configuration of Apache2
①Edit the httpd.conf file
Back up the httpd.conf file httpd-2.4.39]# cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf_bak Edit the httpd.conf file httpd-2.4.39]# vi /usr/local/apache2/conf/httpd.conf |
■Enable digest authentication per line 83
Remove the “#” at the beginning of the line “LoadModule auth_digest_module modules/mod_auth_digest.so”.
■Enable the CGI module per line 171Remove the “#” at the beginning of the line “LoadModule cgid_module modules/mod_cgid.so”.
■Change the ServerName per line 228
Add “ServerName Host Name” under “ServerName www.example.com:80”.
■Per line 252 Change document root
Enter a “#” at the beginning of the line “DocumentRoot “/usr/local/apache2/htdocs”” and comment it out
■Add the following under </Directory> around line 279
<VirtualHost *:80>
ServerAdmin Administrator email address
DocumentRoot /var/www/html/Server IP/
ServerName Server IP
ErrorLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/Server IP_error_log_%Y%m%d 86400 540”
CustomLog “| /usr/local/apache2/bin/rotatelogs /var/log/httpd/Server IP_access_log_%Y%m%d 86400 540”
combined
ErrorDocument 404 /
</VirtualHost>
<Directory “/var/www/html/Server IP”>
Options Indexes Includes FollowSymLinks MultiViews ExecCGI
Require all granted
Allow from all
AddHandler server-parsed .html
</Directory>
■Add index file per line 307
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
■Change the error_log output directory per line 325
Add “#” to the beginning of the line “ErrorLog “logs/error_log”” and add “ErrorLog “/var/log/httpd/error_log”” below it.
and add
■Comment out the log settings per line 355
Add “#” to the beginning of “CustomLog logs/access_log common”.
■Uncomment the CGI script per line 455
Remove the “#” from the beginning of “AddHandler cgi-script .cgi”.
■Enable httpd-default.conf per line 542
Remove the “#” at the beginning of the line “Include conf/extra/httpd-default.conf”.
➁Edit the httpd-default.conf file
httpd-2.4.39]# vi /usr/local/apache2/conf/extra/httpd-default.conf ■Per line 10, change the timeout period. Timeout 240 |
➂Create the necessary directories and set their owners and permissions.
httpd-2.4.39]# mkdir -p /var/www/html/Server IP/ httpd-2.4.39]# mkdir /var/log/httpd httpd-2.4.39]# chown -R <General User Name>:<General User Name> /var/www/ httpd-2.4.39]# chmod 755 /var/www/html/Server IP/ |
④Check httpd.conf file
httpd-2.4.39]# /usr/local/apache2/bin/apachectl configtest Syntax OK |
⑤Auto-start configuration for Apache
httpd-2.4.39]# cd /lib/systemd/system/ Create httpd.service with the following contents |
[Unit] Description=The Apache HTTP Server 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.targe |
⑥Apache Autostart Configuration and Startup
system]# systemctl enable httpd.service system]# systemctl start httpd.service |
⑦Checking the operation of Apache
If you see “index off” when you connect to http://Server IP Address with a browser such as chrome, Apache is running normally.
2.Installation and configuration of PHP ( PHP-7.3.6 )
2-1 advance preparation
Install the software needed to install PHP
[root@Lepard ~]# dnf install xz-devel libxml2-devel [root@Lepard ~]# dnf install libjpeg-turbo-devel [root@Lepard ~]# dnf install libpng-devel [root@Lepard ~]# dnf install freetype freetype-devel [root@Lepard ~]# dnf install libcurl-devel |
2-2 Install PHP
[root@Lepard ~]# cd /usr/local/src src]# wget https://www.php.net/distributions/php-7.3.6.tar.gz src]# tar zxvf php-7.3.6.tar.gz src]# cd php-7.3.6 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-curlphp-7.3.6]# make php-7.3.6]# make install |
2-3 Editing Apache configuration files
php-7.3.6]# vi /usr/local/apache2/conf/httpd.conf ■Per line 188 Add “AddType application/x-httpd-php .php” under “LoadModule php7_module modules/libphp7.so”. |
2-4 Edit the PHP configuration file
php-7.3.6]# cp php.ini-development /usr/local/php7/etc/php.ini php-7.3.6]# vi /usr/local/php7/etc/php.ini |
Edit php.ini with the following information
■Per line 401 ;memory_limit = 128M memory_limit = 512M■Per line 476 ;display_errors = On display_errors = Off■Per line 688 ;post_max_size = 8M post_max_size = 128M■Per line 838 ;upload_max_filesize = 2M upload_max_filesize = 2000M■Per line 945 Add “extension=curl.so” and “extension=openssl.so”. ;extension=xsl extension=curl.so extension=openssl.so■Per line 959 Add “date.timezone = Asia/Tokyo”. ;date.timezone = date.timezone = Asia/Tokyo |
2-5 Generating the curl.so file
src]# cd /usr/local/src/php-7.3.6/ext/curl/ curl]# /usr/local/php7/bin/phpize curl]# ./configure –with-curl -with-php-config=/usr/local/php7/bin/php-config curl]# make curl]# make install curl]# ls -l /usr/local/php7/lib/php/extensions/no-debug-zts-20180731/ -rwxr-xr-x 1 root root 370064 11月11 10:00 curl.so |
2-6 Checking PHP operation
src]# vi /var/www/html/192.168.11.63/test.php <?php phpinfo(); ?> |
Restart Apache
src]# systemctl restart httpd.service |
When you access http://Server IP/test.php with a browser such as chrome, you will see the following screen