PHP8.2 Apache24 Windows10安装步骤

PHP8.2 Apache24 Windows10安装步骤

1、官网地址 https://httpd.apache.org/download.cgi

PHP8.2 Apache24 Windows10安装步骤_第1张图片
PHP8.2 Apache24 Windows10安装步骤_第2张图片
PHP8.2 Apache24 Windows10安装步骤_第3张图片
PHP8.2 Apache24 Windows10安装步骤_第4张图片

修改1:Define SRVROOT “D:\WorkSoft\Apache\Apache24\conf”
ServerRoot “${SRVROOT}”
修改2:
PHP8.2 Apache24 Windows10安装步骤_第5张图片

修改3:

ServerName localhost:8081

PHP8.2 Apache24 Windows10安装步骤_第6张图片

安装Apache服务

让其一直运行

D:\WorkSoft\Apache\Apache24\bin 

.\httpd.exe -k start

启动不成功,如下图管理员运行:

PHP8.2 Apache24 Windows10安装步骤_第7张图片

安装PHP:

官网:https://windows.php.net/download#php-8.2

PHP8.2 Apache24 Windows10安装步骤_第8张图片

复制php.ini-development/php.ini-production ,改为php.ini

PHP8.2 Apache24 Windows10安装步骤_第9张图片

extension_dir = “D:\WorkSoft\PHP\php-8.2.4-Win32-vs16-x64”

PHP8.2 Apache24 Windows10安装步骤_第10张图片


; On windows:
;extension_dir = "ext"
extension_dir = "c:/wsr/php/ext"

设置要加载的扩展文件

命令: D:\WorkSoft\PHP\php-8.2.4-Win32-vs16-x64>dir .\ext\ 
/bphp_bz2.dll
php_com_dotnet.dll
php_curl.dll
php_dba.dll
php_dl_test.dll
php_enchant.dll
php_exif.dll
php_ffi.dll
php_fileinfo.dll
php_ftp.dll
php_gd.dll
php_gettext.dll
php_gmp.dll
php_imap.dll
php_intl.dll
php_ldap.dll
php_mbstring.dll
php_mysqli.dll
php_oci8_19.dll
php_odbc.dll
php_opcache.dll
php_openssl.dll
php_pdo_firebird.dll
php_pdo_mysql.dll
php_pdo_oci.dll
php_pdo_odbc.dll
php_pdo_pgsql.dll
php_pdo_sqlite.dll
php_pgsql.dll
php_shmop.dll
php_snmp.dll
php_soap.dll
php_sockets.dll
php_sodium.dll
php_sqlite3.dll
php_sysvshm.dll
php_tidy.dll
php_xsl.dll
php_zend_test.dll
php_zip.dll

以上文件作为扩展文件加入

;zend_extension=opcache
;扩展文件
extension=php_bz2.dll
extension=php_com_dotnet.dll
extension=php_curl.dll
extension=php_dba.dll
extension=php_dl_test.dll
extension=php_enchant.dll
extension=php_exif.dll
extension=php_ffi.dll
extension=php_fileinfo.dll
extension=php_ftp.dll
extension=php_gd.dll
extension=php_gettext.dll
extension=php_gmp.dll
extension=php_imap.dll
extension=php_intl.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_oci8_19.dll
extension=php_odbc.dll
extension=php_opcache.dll
extension=php_openssl.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=php_shmop.dll
extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sodium.dll
extension=php_sqlite3.dll
extension=php_sysvshm.dll
extension=php_tidy.dll
extension=php_xsl.dll
extension=php_zend_test.dll
extension=php_zip.dll
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

设置时区

[Date]
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
;date.timezone =
date.timezone = Asia/Shanghai

4、设置openssl

设置httpd.conf
D:\WorkSoft\Apache\Apache24\conf

1、设置默认索引

#DirectoryIndex: sets the file that Apache will serve if a directory
 is requested.
#

    # DirectoryIndex index.html
    DirectoryIndex index.html index.htm index.php

2、开启 rewrite 功能。将下面第2行的注释去掉即可。

#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so

3、在文件末尾添加如下设置。

#php8
LoadModule php_module "D:/WorkSoft/PHP/php-8.2.4-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "D:/WorkSoft/PHP/php-8.2.4-Win32-vs16-x64"
AddType application/x-httpd-php .php .html

重启Apache服务器

 .\httpd.exe -k restart

在这里插入图片描述

验证效果

在D:\WorkSoft\Apache\Apache24\htdocs\目录下分别新建index.php、dir1\test.html:
Index.php内容:


Dir1\test.html内容:





";
echo "Hello World!
"; EcHo "Hello World!
"; ?>

在浏览器地址栏分别访问http://localhost:8081/index.php、http://localhost:8081/dir1/test.html,可以看到如下的效果:

PHP8.2 Apache24 Windows10安装步骤_第11张图片
PHP8.2 Apache24 Windows10安装步骤_第12张图片

说明
其中,目录D:\WorkSoft\Apache\Apache24\htdocs为部署项目的目录,如果不想使用默认值,可以修改配置文件D:\WorkSoft\Apache\Apache24\conf\httpd.conf,将DocumnetRoot的值修改为其它的:

#
#DocumentRoot: The directory out of which you will serve your
#documents. By default, all requests are taken from this directory, but
#symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "c:/Users/fy/Desktop/project"
#


    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

每次修改配置文件后都需要重启Apache服务,否则修改不生效。至此,所有配置结束。

你可能感兴趣的:(php,apache,windows)