如何使用多个XAMPP,例如XAMPP PHP版本5,XAMPP PHP版本7,版本8。
当我运行XAMPP php版本7时,一切都很好,但是当我运行XAMPP php版本8时,我当前的项目不起作用“ nofollow noreferrer”>这是我的Laravel 9 XAMPP PHP版本8当前项目
,当我运行新项目并安装NPM安装& NPM运行开发人员,但行不通 npm安装 当我运行npm运行dev时,此结果 npm run dev
以及我运行PHP Artisan Migrant and ofrisan迁移和迁移和此后服务登录URL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您可以使用单个XAMPP安装同时使用多个PHP版本时,为什么要在PHP版本之间切换?
使用单个XAMPP安装,您有2个选项:
仅针对您的旧项目目录运行较旧的PHP版本:这将为目的提供大多数目的时间。您可能有一个或两个旧项目,您打算使用较旧的PHP版本运行。只需配置XAMPP即可运行较旧的PHP版本。
在XAMPP的单独端口上运行较旧的PHP版本:有时您可能会升级一个旧项目到最新的PHP版本,同时您需要来回运行同一项目在新的PHP版本和旧的PHP版本之间。为此,您可以在其他端口(例如8056)上设置较旧的PHP版本,因此,当您转到
http:// localhost/any_project/
时,xampp运行php 7,然后转到http:// localhost:8056/any_project/ xampp运行PHP 5.6。
在VirtualHost上运行较旧的PHP版本:您可以创建像LocalHost56这样的VirtualHost运行PHP 5.6,而您可以在LocalHost上使用PHP 7。
让我们将其设置为
步骤1:下载php
,以便在XAMPP下运行的PHP 7,您想向其添加较旧的PHP版本(例如PHP 5.6)。从 php.net (请参阅存档对于较旧版本),并根据
c:\ xampp \ php56
提取文件。线程安全版本不包括php-cgi.exe。步骤2:配置
php.ini
打开文件
c:\ xampp \ php56 \ php56 \ php.ini
在记事本中。如果文件不存在,请将php.ini-development
复制到php.ini
并在记事本中打开。然后输入以下行:另外,如果以下行存在于Apache config
httpd-xampp.conf
中,并用领先的#(哈希字符)将其评论。
步骤3:配置Apache
Open XAMPP控制面板,单击Apache的配置按钮,然后单击
apache(httpd-xampp.conf)
。文本文件将打开。将以下设置放在文件的底部:注意: 您可以在第1到3之后在第1到3的XAMPP安装中添加更多版本的PHP。
步骤4(选项1): [添加目录以运行特定的PHP版本]
现在您可以设置将在PHP 5.6中运行的目录。只需在配置文件的底部添加以下内容(
httpd-xampp.conf.conf
从步骤3)设置目录。上运行较旧的PHP版本]
步骤4(选项2): [在单独的端口 配置文件的底部(
httpd-xampp.conf
从步骤3中)。步骤4(选项3): [在VirtualHost上运行较旧的PHP版本]
在目录(HTDOCS56)上创建VirtualHost(LocalHost56)使用PHP v5.6在http:// localhost56上,在您想要的位置创建目录htdocs56,
将localhost56添加到您的主机文件(请参见如何),
然后将以下代码添加到配置文件的底部(
httpd-xampp.conf.conf
从步骤3)。完成:保存并重新启动Apache
保存并关闭配置文件。从XAMPP控制面板重新启动Apache。如果您选择了选项2,则可以看到XAMPP控制面板中列出的其他端口(8056)。
有关更多信息,请查看此线程:是否可以在xampp中使用两个PHP?
Why switch between PHP versions when you can use multiple PHP versions at the same time with a single xampp installation?
With a single xampp installation, you have 2 options:
Run an older PHP version for only the directory of your old project: This will serve the purpose most of the time. You may have one or two old projects that you intend to run with an older PHP version. Just configure xampp to run an older PHP version for only those project directories.
Run an older PHP version on a separate port of xampp: Sometimes you may be upgrading an old project to the latest PHP version and at the same time you need to run the same project back and forth between the new PHP version and the old PHP version. To do this you can set an older PHP version on a different port (say 8056) so when you go to
http://localhost/any_project/
, xampp runs PHP 7 and when you go tohttp://localhost:8056/any_project/
xampp runs PHP 5.6.Run an older PHP version on a virtualhost: You can create a virtualhost like localhost56 to run PHP 5.6 while you can use PHP 7 on localhost.
Lets set it up
Step 1: Download PHP
So you have PHP 7 running under xampp, you want to add an older PHP version to it (say PHP 5.6). Download the nts (Non Thread Safe) version of the PHP zip archive from php.net (see archive for older versions) and extract the files under
c:\xampp\php56
. The thread safe version does not include php-cgi.exe.Step 2: Configure
php.ini
Open the file
c:\xampp\php56\php.ini
in notepad. If the file does not exist, copyphp.ini-development
tophp.ini
and open it in notepad. Then uncomment the following line:Also if the following line exists in Apache config
httpd-xampp.conf
comment it out with with a leading # (hash character).
Step 3: Configure apache
Open xampp control panel, click the config button for apache, and click
Apache (httpd-xampp.conf)
. A text file will open. Put the following settings at the bottom of the file:Note: You can add more versions of PHP to your xampp installation following step 1 to 3 if you want.
Step 4 (option 1): [Add Directories to run a specific PHP version]
Now you can set directories that will run in PHP 5.6. Just add the following at the bottom of the config file (
httpd-xampp.conf
from Step 3) to set directories.Step 4 (option 2): [Run an older PHP version on a separate port]
Now to to set PHP v5.6 on port 8056, add the following code to the bottom of the config file (
httpd-xampp.conf
from Step 3).Step 4 (option 3): [Run an older PHP version on a virtualhost]
To create a virtualhost (localhost56) on a directory (htdocs56) to use PHP v5.6 on http://localhost56, create directory htdocs56 at your desired location and
add localhost56 to your hosts file (see how),
then add the following code to the bottom of the config file (
httpd-xampp.conf
from Step 3).Finish: Save and Restart Apache
Save and close the config file. Restart apache from the xampp control panel. If you went for option 2, you can see the additional port(8056) listed in your xampp control panel.
For more information, take a look at this thread: Is there way to use two PHP versions in XAMPP?