Let's talk about Nginx and Apache configuring multiple versions of PHP

藏色散人
Release: 2023-04-11 10:44:01
forward
3969 people have browsed it

This article brings you relevant knowledge about PHP. It mainly talks about how to configure multiple versions of PHP for Nginx and Apache, and how to cut multiple conf files. Interested friends will take a look below. Let's take a look, hope it helps everyone.

Let's talk about Nginx and Apache configuring multiple versions of PHP

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 (unselected)

Add

include vhosts/*.conf;
Copy after login
# in nginx.conf ##In this way, Nginx will automatically import all *.conf files in the current directory->vhosts directory, making it easier for each project to manage the Nginx configuration file independently

Configuring multiple versions of PHP

Add

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; } }
Copy after login

  • fastcgi_pass is the PHP execution IP port in the conf file

  • fastcgi_index default PHP file

  • fastcgi_split_path_info is regular

  • fastcgi_param is the directory where PHP is located (Nginx will automatically obtain and assign the value to $fastcgi_script_name)

Assume we have If you have two PHP versions, one PHP5 and one PHP7, you can run them on different ports respectively, and then set the fastcgi_pass parameter to achieve different PHP versions for each project

Apache


Cut conf (not optional)

Add

Include conf/vhosts/*.conf
Copy after login

in httpd.conf so that Apache will automatically introduce the Apache installation directory->conf ->All *.conf files in the vhosts directory to facilitate each project to manage the Apache configuration file independently

Configuring multiple versions of PHP

Add # in the conf file ##
FcgidInitialEnv PHPRC "D:/Extensions/php/php8.2.2-nts" AddHandler fcgid-script .php FcgidWrapper "D:/Extensions/php/php8.2.2-nts/php-cgi.exe" .php
Copy after login

Just specify the corresponding directory.

Recommended learning: "

PHP Video Tutorial

"

The above is the detailed content of Let's talk about Nginx and Apache configuring multiple versions of PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!