I have a new vps which has Ubuntu 22.04 installed and Apache/2.4.52 (Ubuntu). I have SSL installed on this machine, and created a Virtual Host which looks like this:
<VirtualHost *:443>
ServerName dev.jts.co.uk
ServerAdmin [email protected]
DocumentRoot /var/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www">
Options +ExecCGI +Indexes
AllowOverride All
Require all granted
</Directory>
<Directory "/var/www/pt/pt_v1">
# Disable PHP 7.4 engine
php_value engine off
# Enable PHP 5.6 via CGI
AddHandler application/x-httpd-php5 .php .htm .html .cgi
Action application/x-httpd-php5 /cgi-bin/php-cgi5.6
Options +ExecCGI
AllowOverride None
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin
SSLCertificateFile /etc/letsencrypt/live/dev.jts.co.uk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/dev.jts.co.uk/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
This is one of many veriations of the .conf file, I have tried many more, including .htaccess directives, all have made the phpinfo.php show in plain text, or download.
The default php is php 7.4, which is used in the root folder, but the /pt/.. folders will need to be run via cgi. starting with php-cgi5.6
I am trying to run dev.jts.co.uk/jts/jts_v1/phpinfo.php which consists of this code:
<?php phpinfo();
But it only gives me this in plain text.
I can run it from the commandline using /var/www/cgi-bin$ ./php-cgi5.6 < /var/www/pt/pt_v1/phpinfo.php and this seems to working and display. So i am confident the php-cgi is ok.
The module is enabled sudo a2enmod cgi.
The issue seems to be how Apache is interpreting it, and not executing it. I have check permissions for folder, and files which are correct. I have exhausted all google search which focus on httpd.conf rather than the latest apache2 and Virtual Hosts. I have asked OpenAI ChatGPT to look at it, who has exhausted all ideas. None seem to work.
Due the nature of the issue it must be something simple i am missing. Can anyone help me please?
Thank you Lazy
Did you try
actually, panels like virtualmin do it in this way. Hope
/cgi-bin/php-cgi5.6is the actual cgi wrapper.EDIT: i make vps with ubuntu 20.04, apache2 and php5.6-cgi and 8.1-cgi installed. this is my virtual host. i used
a2disconf php5.6-cgianda2disconf php8.1-cgi,a2enmod cgidand this is config on clen system:
all works fine. i think you can add other php version as php-fpm and switch where you need.