简体   繁体   English

如何在XAMPP上安装PHP 8

[英]How to install PHP 8 on XAMPP

I'm trying to update my PHP version to the brand new PHP 8. I have followed simular steps as this tutorial.我正在尝试将我的 PHP 版本更新为全新的 PHP 8. 我已按照与 教程类似的步骤进行操作。 But now the following error is shown:但是现在显示以下错误:

12:06:23  [Apache]  Error: Apache shutdown unexpectedly.
12:06:23  [Apache]  This may be due to a blocked port, missing dependencies, 
12:06:23  [Apache]  improper privileges, a crash, or a shutdown by another method.
12:06:23  [Apache]  Press the Logs button to view error logs and check
12:06:23  [Apache]  the Windows Event Viewer for more clues
12:06:23  [Apache]  If you need more help, copy and post this
12:06:23  [Apache]  entire log window on the forums

Notice: I have used a brand new XAMPP instalation version 7.2.33.注意:我使用的是全新的 XAMPP 安装版本 7.2.33。

I can't find the solution for my issue.我找不到我的问题的解决方案。

Edit It is saying that I need to look into the Log files hower they are completly empty since it's a brand new installation.编辑据说我需要查看日志文件,但它们完全是空的,因为它是全新安装。

This is my httpd-xampp.conf :这是我的httpd-xampp.conf

<IfModule env_module>
    SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
    SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
    SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
    SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
    SetEnv PHPRC "\\xampp\\php"
    SetEnv TMP "\\xampp\\tmp"
</IfModule>

#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php8ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php8_module "C:/xampp/php/php8apache2_4.dll"
LoadFile "C:/xampp/php/libsqlite3.dll"

<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
#    SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
#    Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>


<IfModule php8_module>
    PHPINIDir "C:/xampp/php"
</IfModule>

<IfModule mime_module>
    AddType text/html .php .phps
</IfModule>

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

<Directory "C:/xampp/cgi-bin">
    <FilesMatch "\.php$">
        SetHandler cgi-script
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler None
    </FilesMatch>
</Directory>

<Directory "C:/xampp/htdocs/xampp">
    <IfModule php8_module>
        <Files "status.php">
            php_admin_flag safe_mode off
        </Files>
    </IfModule>
    AllowOverride AuthConfig
</Directory>

<IfModule alias_module>
    Alias /licenses "C:/xampp/licenses/"
    <Directory "C:/xampp/licenses">
        Options +Indexes
        <IfModule autoindex_color_module>
            DirectoryIndexTextColor  "#000000"
            DirectoryIndexBGColor "#f8e8a0"
            DirectoryIndexLinkColor "#bb3902"
            DirectoryIndexVLinkColor "#bb3902"
            DirectoryIndexALinkColor "#bb3902"
        </IfModule>
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
   </Directory>

    Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
    <Directory "C:/xampp/phpMyAdmin">
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>

    Alias /webalizer "C:/xampp/webalizer/"
    <Directory "C:/xampp/webalizer">
        <IfModule php8_module>
            <Files "webalizer.php">
                php_admin_flag safe_mode off
            </Files>
        </IfModule>
        AllowOverride AuthConfig
        Require local
        ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
    </Directory>
</IfModule>

Rewriting php8_module to php_module (all occurrences) inphp8_module重写为php_module (所有出现)

"httpd-xampp.conf" file solved the Error: Apache shutdown unexpectedly problem for me:) “httpd-xampp.conf”文件解决了我的Error: Apache shutdown unexpectedly问题:)

Running PHP 8 on XAMPP is easy now since XAMPP new version released with PHP 8 update.现在在 XAMPP 上运行 PHP 8 很容易,因为 XAMPP 新版本随 Z2FEC392304A5F9B3AC77 更新发布。 Install XAMPP, and run first PHP program using XAMPP Server on localhost.安装 XAMPP,并在 localhost 上使用 XAMPP 服务器运行第一个 PHP 程序。 Following are the steps:以下是步骤:

  • Download and Install XAMPP下载并安装 XAMPP
  • Create a new project in XAMPP and add your PHP program在 XAMPP 中创建一个新项目并添加您的 PHP 程序
  • Open XAMPP and run your first PHP program打开 XAMPP 并运行您的第一个 PHP 程序

Download and Install XAMPP下载并安装 XAMPP

Step 1 : Go to the Apache Friends website and download XAMPP Server (supporting PHP 8). Step 1 : Go 到 Apache 好友网站并下载 XAMPP 服务器(支持 Z2FEC73Z88224A5C23)。 Apache Friends is the official website to download XAMPP: Apache朋友是官网下载XAMPP:

Download XAMPP下载 XAMPP

Step 2 : After downloading, install it.第二步:下载后安装。 You can install it at any location.您可以将其安装在任何位置。 We installed XAMPP ie C: drive,我们安装了 XAMPP 即 C:驱动器,

Create a new project in XAMPP在 XAMPP 中新建工程

Step 3 : Now, go to htdocs folder in Xampp folder and create your project folder.第 3 步:现在,go 到 Xampp 文件夹中的htdocs文件夹并创建您的项目文件夹。

Here, a folder AmitProject created, as in the below screenshot:在这里,创建了一个 AmitProject 文件夹,如下图所示:

Follow this tutorial and you won't need to update any settings shown above.按照教程进行操作,您无需更新上面显示的任何设置。

  1. rename old php dir to phpX将旧的 php 目录重命名为 phpX
  2. Download the needed version of PHP + dev pack, ex.: https://windows.php.net/download#php-8.0下载所需版本的 PHP + 开发包,例如: https://windows.php.net/download#php-8.0
  3. extract to xampp/php the donwloaded archives将下载的档案提取到 xampp/php
  4. if old php configs matters for you, copy phpX/php.ini to php/如果旧的 php 配置对您很重要,请将 phpX/php.ini 复制到 php/
  5. extract into xampp, rewrite the referring phpOld lines in httpd-xampp.config解压成xampp,改写httpd-xampp.config中引用的phpOld行
  • Instead of phpX_module, use just php_module而不是 phpX_module,只使用 php_module
  1. if problem persists, running xampp_start gives PHP load error: %1 is not a valid Win32 application.如果问题仍然存在,运行 xampp_start 会给出PHP load error: %1 is not a valid Win32 application. then also download new apache version...然后还下载新的 apache 版本...
  • don't forget to put at thier place the httpd.conf, httpd-ssl.conf, httpd-xampp.conf不要忘记将 httpd.conf、httpd-ssl.conf、httpd-xampp.conf 放在他们的位置

Or instead of downloading the modules separately, just do a new XAMPP installation with the desired version and copy php+apache dirs, then unistall the old one.或者不用单独下载模块,只需使用所需版本安装新的 XAMPP 并复制 php+apache 目录,然后卸载旧的。 From the old apache dir get the httpd*.conf files or correct their paths.从旧的 apache 目录获取 httpd*.conf 文件或更正它们的路径。

This error is the result of an xampp misconfiguration for the new php version (means wrong entries in xampp/apache/conf/extra/httpd-xampp.conf).此错误是新 php 版本的 xampp 配置错误的结果(表示 xampp/apache/conf/extra/httpd-xampp.conf 中的条目错误)。

Luckily, you can check the configuration of the apache server with this shell command:幸运的是,您可以使用以下 shell 命令检查 apache 服务器的配置:

c:/xampp/apache/bin/httpd.exe -t

(Replace the drive letter with your installation drive letter, also change the xampp folder if you have xampp installed in a custom folder.) (将驱动器号替换为您的安装驱动器号,如果您在自定义文件夹中安装了 xampp,则还要更改 xampp 文件夹。)

If you see Syntax OK php should work basically (don't forget to copy/adjust the php.ini file).如果您看到Syntax OK php 应该基本上可以工作(不要忘记复制/调整 php.ini 文件)。 If not, the output of httpd.exe -t offer useful hints what should be changed in httpd-xampp.conf.如果没有, httpd.exe -t的 output 会提供有用的提示,提示应该在 httpd-xampp.conf 中更改哪些内容。

IN https://windows.php.net/download#php-8.0https://windows.php.net/download#php-8.0

What is very important you have to download the "Thread Safe" version.非常重要的是您必须下载“线程安全”版本。 otherwise you have no "php8apache2_4.dll" and you need that so that php8 works with apache in XAMPP.否则你没有“php8apache2_4.dll”,你需要这样 php8 在 XAMPP 中与 apache 一起工作。

I choose this way我选择这条路

Back up your XAMPP and htdocs files, then uninstall XAMPP, Download New XAMPP Version, Install XAMPP configure the path to your back-up htdocs files or Project Files -> httpd.config备份您的 XAMPP 和 htdocs 文件,然后卸载 XAMPP,下载新的 XAMPP 版本,安装 XAMPP 配置备份 htdocs 文件或项目文件的路径 -> httpd.config

you should find this so that you can customize the path你应该找到这个,这样你就可以自定义路径

DocumentRoot "D:\PROJECT"
<Directory "D:\PROJECT">

Hi @IMSoP did you get make it work?嗨@IMSoP,你让它工作了吗? i have the same problem and nothing works for me, i tried with @Honza Jahoda's solution, but it doesnt work for me.我有同样的问题,对我没有用,我尝试了@Honza Jahoda 的解决方案,但它对我不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM