SETTING UP APACHE / PHP

tested on Slackware Linux current (Jan 2021)

and assuming SSL is rather done with NGINX

INSTALL

apachectl script wants lynx

slackpkg install httpd apr apr-utils sqlite icu4c mariadb lynx
ldd /usr/sbin/httpd
which httpd
httpd -V
apachectl -t

ls -lF /etc/rc.d/rc.httpd
chmod +x /etc/rc.d/rc.httpd
/etc/rc.d/rc.httpd start

enabling PHP

slackpkg install php-7 libxml2 libedit libsodium

php extensions - we only need to fix the libs for the extensions we need - e.g. for Moodle we are missing libs for extensions mbstring zip gd curl

slackpkg install gd-2 brotli fontconfig oniguruma libzip freetype libXpm libX11 libwebp harfbuzz libxcb graphite2 libXau libXdmcp curl nghttp2 brotli

php -m >/dev/null

and no need for missing libs for extensions enchant odbc pdo_odbc snmp xsl - disable quite a few irrelevant extensions

diff -bu /etc/php.ini-production /etc/php.ini # the same
cp -pi /etc/php.ini /etc/php.ini.dist
vi /etc/php.ini

;extension=enchant
;extension=odbc
;extension=pdo_odbc
;extension=pspell
;extension=snmp
;extension=tidy
;extension=xsl

date.timezone = Europe/Moscow

try again and apply

    php -m >/dev/null

apachectl -t
apachectl restart

PHP MWE

tested on Slackware

vi /etc/httpd/httpd.conf

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Include /etc/httpd/mod_php.conf

is this a bug?

vi /etc/httpd/mod_php.conf

#LoadModule php7_module lib64/httpd/modules/libphp7.so
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so

vi /var/www/htdocs/info.php

<?php phpinfo(); ?>

apachectl restart

check locally

curl -I localhost/info.php
lynx -dump localhost/info.php

check from the host

curl -I 10.9.9.1/info.php
lynx -dump 10.9.9.1/info.php

VIRTUAL HOSTS

see apache-vhost

SSL

if you really don’t need a reverse-proxy to do the job, then see apache-ssl

CLIENT CERTIFICATES

see apache-clientcert

OPERATIONS

tail -F /var/log/httpd/*

check and reload

apachectl -t
apachectl restart

status

ps auxfww | grep httpd | grep -vE 'grep|tail'
    netstat -lntupe

TODO

hide apache and php versions (seen in the HTTP headers)

Resources

HostnameLookups Directive http://httpd.apache.org/docs/2.4/mod/core.html#hostnamelookups

Setup Apache, PHP and MySQL https://docs.slackware.com/howtos:network_services:setup_apache_php_mysql

LAMP on Slackware. http://www.slackware.com/~mrgoblin/slackware-lamp.php http://www.slackware.com/~mrgoblin/slackware-lamp2.php

Web Server Management: Running Apache 2.2 under Linux https://www.cl.cam.ac.uk/~jw35/courses/apache/html/book1.htm


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun