Issue
There are a lot of posts on the internet explaining how to configure a LAMP environment but there are very few articles describing how to configure an existing Apache server to use PHP, considering that Apache is already installed at another location then the default one.
Such a scenario I encountered in the case of an AWS Lightsail Node.js stack which came with Apache installed but no PHP module configured.
Does anyone have any idea how to configure an existing Apache installation to work with PHP?
Solution
After doing some research I've found the necessary steps to do the configuration (for Ubuntu):
- Run
sudo apt-get update
to get the newest list of available software packages - Install PHP by runing:
sudo apt-get install php libapache2-mod-php
- Run
sudo find / -name libphp*
to get the location of thelibphpX.X.so
file - Copy the
libphpX.X.so
file into the Apachemodules
folder - Open the Apache
httpd.conf
file and add at the end the following lines:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
- Restart apache server
Answered By - Razvan-Catalin Olaru