ubuntu 18.4: how to get php 7.2 to work with apache 2?

383 views Asked by At

I purchased a virtual server from vpscity, and chose the Ubuntu 18.4 64bit image.

it came with apache 2 installed.

i am trying to get webpagetest server installed using these instructions: https://docs.webpagetest.org/private-instances/

I did this:

sudo apt-get update &&
sudo apt-get -y dist-upgrade &&
sudo apt-get -y install zip python2.7 nginx php-fpm php-cli php-xml php-apcu php-gd php-zip php-mbstring php-curl php-sqlite3 beanstalkd imagemagick ffmpeg libjpeg-turbo-progs libimage-exiftool-perl python-setuptools python-dev build-essential python-pip python-numpy python-scipy &&
sudo pip install monotonic ujson pillow pyssim

And restarted apache.

However, when I view the website, I see raw php code.

the instructions say:

Using the PHP DSO handler mod_php can dramatically reduce the CPU required when working with large numbers of agents uploading results.

But I dont know what this means or how to implement.

If I look in /etc/apache2/mods-available

I dont see anything with php in it.

There are various people with the same problem, and several different conflicting answers such as:

AddType application/x-httpd-php .php
AddType application/x-httpd-phps .phps
AddType application/x-httpd-php3 .php3 .phtml
AddType application/x-httpd-php .html
LoadModule php7_module modules/mod_php.so
AddModule mod_php7.c
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
service apache2 reload
a2enmod php7.0
service apache2 restart
sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart
gksu gedit /etc/apache2/apache2.conf
sudo apt-get install -y php5-gd php5-curl php-apc libapache2-mod-php5 ffmpeg imagemagick libjpeg-progs libimage-exiftool-perl
sudo a2enmod php5

I never thought getting apache to work with php would be this difficult.

I just noticed that the apt-get I did has nginx in it. Thats not good. Maybe there is a conflict, and I need to re-build the server and do it again without nginx? I dont see nginx running (only apache).

php -version
PHP 7.2.24-0ubuntu0.18.04.15 (cli) (built: Nov  2 2022 09:09:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-0ubuntu0.18.04.15, Copyright (c) 1999-2018, by Zend Technologies
1

There are 1 answers

0
John Little On

After much trial and error, this one worked:

apt-get -y install libapache2-mod-php7.2
systemctl restart apache2