Switch php version on specific location using nginx

Flex

New member
Joined
Jul 9, 2018
Messages
1
Hello,

I need to know hoy to swtich php version for a specific location.

Code:
www.domain.com/ must use php 5
www.domain.com/subfolder must use php 7

This is for a fresh install of Directadmin with PHP7 a PHP5, nginx (without apache).

Anyone can help me?
 
A. I assume you are using PHP-FPM.

B. I assume you use PHP 7.2.

C. I assume the main PHP version for the account is 5.6 (or 5.something).

Now...

1. In the subfolder create a file with name .htaccess and put inside this:

AddHandler "proxy:unix:/usr/local/php72/sockets/USER.sock|fcgi://localhost" .inc .php .phtml .php72

where you need to change "USER" with the username of the account.

2. In case the above do not work, you may need to edit a custom httpd configuration for the user. Check this guide: https://help.directadmin.com/item.php?id=3

Check out the /usr/local/directadmin/data/users/USER/httpd.conf file for example of how it handles virtual hosts.

P.S. Note that Directadmin handles the subdomains in subfolders (subfolder.domain.tld is the same as domain.tld/subfolder). For that reason you can practically add a subdomain in DA and edit it's VirtualHost to work with PHP 7 - it will work.
 
Back
Top