Home >Operation and Maintenance >Nginx >How to configure multiple versions of PHP with Nginx and Apache
Sometimes our projects cannot all have the same PHP version, and each project needs to be configured with a different version of PHP. Pagoda and PHPStudy are implemented through the following configuration:
Nginx
Cut conf (not optional)
Add
include vhosts/*.conf;
in nginx.conf so that Nginx will automatically import the current directory ->All *.conf files in the vhosts directory to facilitate each project to manage the Nginx configuration file independently
Configuring multiple versions of PHP
Add # in the conf file ##
server { listen 80; server_name localhost; root "D:/WWW"; location / { index index.php index.html; include D:/WWW/nginx.htaccess; autoindex on; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9010; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
Apache
cutting conf (not optional)
AddInclude conf/vhosts/*.confin httpd.conf so that Apache will automatically import all *.conf files in the Apache installation directory->conf->vhosts directory , to facilitate each project to manage the Apache configuration file independently
Configuring multiple versions of PHP
Just addFcgidInitialEnv PHPRC "D:/Extensions/php/php8.2.2-nts" AddHandler fcgid-script .php FcgidWrapper "D:/Extensions/php/php8.2.2-nts/php-cgi.exe" .phpto the conf file to specify the corresponding directory.
The above is the detailed content of How to configure multiple versions of PHP with Nginx and Apache. For more information, please follow other related articles on the PHP Chinese website!