如何使用多个XAMPP,例如XAMPP PHP版本5,XAMPP PHP版本7,版本8。

发布于 2025-02-13 04:29:57 字数 629 浏览 1 评论 0 原文

当我运行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

when i run xampp php version 7 all are good but when i run xampp php version 8 but my current project not work this is my laravel 9 xampp php version 8 current project

and another problem when i run new project and install npm install && npm run dev but it's not work
npm install
and when I run npm run dev this result npm run dev

and when I run php artisan migrate and serve after then login url

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖心男生 2025-02-20 04:29:57

当您可以使用单个XAMPP安装同时使用多个PHP版本时,为什么要在PHP版本之间切换?

使用单个XAMPP安装,您有2个选项:

  1. 仅针对您的旧项目目录运行较旧的PHP版本:这将为目的提供大多数目的时间。您可能有一个或两个旧项目,您打算使用较旧的PHP版本运行。只需配置XAMPP即可运行较旧的PHP版本。

  2. 在XAMPP的单独端口上运行较旧的PHP版本:有时您可能会升级一个旧项目到最新的PHP版本,同时您需要来回运行同一项目在新的PHP版本和旧的PHP版本之间。为此,您可以在其他端口(例如8056)上设置较旧的PHP版本,因此,当您转到 http:// localhost/any_project/时,xampp运行php 7,然后转到 http:// localhost:8056/any_project/ xampp运行PHP 5.6。

  3. 在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 并在记事本中打开。然后输入以下行:

extension_dir = "ext"

另外,如果以下行存在于Apache config httpd-xampp.conf 中,

SetEnv PHPRC "\\path\\to\\xampp\\php"

并用领先的#(哈希字符)将其评论。

步骤3:配置Apache

Open XAMPP控制面板,单击Apache的配置按钮,然后单击 apache(httpd-xampp.conf)。文本文件将打开。将以下设置放在文件的底部:

ScriptAlias /php56 "C:/xampp/php56"
Action application/x-httpd-php56-cgi /php56/php-cgi.exe
<Directory "C:/xampp/php56">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

注意: 您可以在第1到3之后在第1到3的XAMPP安装中添加更多版本的PHP。

步骤4(选项1): [添加目录以运行特定的PHP版本]

现在您可以设置将在PHP 5.6中运行的目录。只需在配置文件的底部添加以下内容( httpd-xampp.conf.conf 从步骤3)设置目录。

<Directory "C:\xampp\htdocs\my_old_project1">
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</Directory>

<Directory "C:\xampp\htdocs\my_old_project2">
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</Directory>

上运行较旧的PHP版本]

步骤4(选项2): [在单独的端口 配置文件的底部( httpd-xampp.conf 从步骤3中)。

Listen 8056
<VirtualHost *:8056>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

步骤4(选项3): [在VirtualHost上运行较旧的PHP版本]

在目录(HTDOCS56)上创建VirtualHost(LocalHost56)使用PHP v5.6在http:// localhost56上,在您想要的位置创建目录htdocs56,
将localhost56添加到您的主机文件(请参见如何),
然后将以下代码添加到配置文件的底部( httpd-xampp.conf.conf 从步骤3)。

<VirtualHost localhost56:80>
    DocumentRoot "C:\xampp\htdocs56"
    ServerName localhost56
    <Directory "C:\xampp\htdocs56">
        Require all granted    
    </Directory>
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

完成:保存并重新启动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:

  1. 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.

  2. 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 to http://localhost:8056/any_project/ xampp runs PHP 5.6.

  3. 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, copy php.ini-development to php.ini and open it in notepad. Then uncomment the following line:

extension_dir = "ext"

Also if the following line exists in Apache config httpd-xampp.conf

SetEnv PHPRC "\\path\\to\\xampp\\php"

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:

ScriptAlias /php56 "C:/xampp/php56"
Action application/x-httpd-php56-cgi /php56/php-cgi.exe
<Directory "C:/xampp/php56">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

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.

<Directory "C:\xampp\htdocs\my_old_project1">
    <FilesMatch "\.php
quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</Directory>

<Directory "C:\xampp\htdocs\my_old_project2">
    <FilesMatch "\.php
quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</Directory>

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).

Listen 8056
<VirtualHost *:8056>
    <FilesMatch "\.php
quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

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).

<VirtualHost localhost56:80>
    DocumentRoot "C:\xampp\htdocs56"
    ServerName localhost56
    <Directory "C:\xampp\htdocs56">
        Require all granted    
    </Directory>
    <FilesMatch "\.php
quot;>
        SetHandler application/x-httpd-php56-cgi
    </FilesMatch>
</VirtualHost>

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.

xampp control panel showing apache running with configured ports

For more information, take a look at this thread: Is there way to use two PHP versions in XAMPP?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文