I have compiled Apache2 2.4.57 with a custom OpenSSL version, then installed php8.2. It is a test web server I used locally on localhost:8080. The server works with the test page of Apache.
Apache2 is installed under /usr/local/apache2
I used sudo a2enmod php8.2 to enable PHP.
I created a test.php page and copied it under htdocs:
<?php
phpinfo();
?>
to test the PHP install but it doesn’t work. When I type localhost:8080/test.php in Chrome it only shows the page’s code.
I’m not a web dev at all. I followed the following tutorial https://computingforgeeks.com/how-to-install-php-8-2-on-ubuntu/
Is there anything else to do in the httpd.conf to enable PHP?
Is it normal that after running sudo a2enmod php8.2 I see no modification in httpd.conf?
I have also tried to use php8.2-fpm but it doesn’t work either.
I’m just planning to stream a simple video to a video player (ffplay) using https with my custom version of OpenSSL.
I thought that Apache+php was simple to install but it seems impossible to configure 🙁
Anyone could help?
Thanks
2
Answers
Thanks Yeung
I followed your advice and managed to compile php8.2 with my Apache version.
I followed the following information: https://gist.github.com/z2z/3bf4c60b7f0c0171d410d54bad088e6e
However, I found out that there were a couple of differences once PHP was compiled. For my purpose, I didn't need any DB so I removed the DB dependencies.
My apache is installed there: /usr/local/apache2/ I have a customed version of openssl there: /usr/local/bin/openssl
Apache compilation is configured in the following way:
php8.5 compilation is configured in the following way:
Both compiled and installed with:
The installation requires running (I don't know why...):
Once compiled php8.2 creates the module: php_module for apache2. It can be verified using:
It also creates the library libphp.so under modules.
To activate php I added the following to httdp.conf
Then I created a php file in htdocs with:
to verify that PHP works!
Fortunately, all this would only be required if you need to use PHP with a custom compilation of Apache2!
a2enmod
is a command tools by Debian / Ubuntu written specifically to support theirapache2
package. It is NOT a tool to support custom compiled Apache2. To use PHP with it, you need to manually compile PHP from source code against your compiled copy of Apache2.This is not recommended because you’d have to manually patch and update your Apache to avoid vulnerability of old version being exploit.
If you do not have a preference to PHP version, you should try to install PHP in one of 2 ways:
The first method should be more straight forward:
If you need PHP 8.2 on your Ubuntu server but still want to use stock Apache package, then you should install PHP 8.2 with PPA:
P.S. PHP-FPM is very flexible if you need to run multiple PHP versions in parallel. But that would take you a lot more understanding in what you’re doing.