PHP8.2 Apache24 Windows10安装步骤
1、官网地址 https://httpd.apache.org/download.cgi
修改1:Define SRVROOT “D:\WorkSoft\Apache\Apache24\conf”
ServerRoot “${SRVROOT}”
修改2:
修改3:
ServerName localhost:8081
安装Apache服务
让其一直运行
D:\WorkSoft\Apache\Apache24\bin .\httpd.exe -k start
启动不成功,如下图管理员运行:
安装PHP:
官网:https://windows.php.net/download#php-8.2
复制php.ini-development/php.ini-production ,改为php.ini
extension_dir = “D:\WorkSoft\PHP\php-8.2.4-Win32-vs16-x64”
; 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.dllphp_com_dotnet.dllphp_curl.dllphp_dba.dllphp_dl_test.dllphp_enchant.dllphp_exif.dllphp_ffi.dllphp_fileinfo.dllphp_ftp.dllphp_gd.dllphp_gettext.dllphp_gmp.dllphp_imap.dllphp_intl.dllphp_ldap.dllphp_mbstring.dllphp_mysqli.dllphp_oci8_19.dllphp_odbc.dllphp_opcache.dllphp_openssl.dllphp_pdo_firebird.dllphp_pdo_mysql.dllphp_pdo_oci.dllphp_pdo_odbc.dllphp_pdo_pgsql.dllphp_pdo_sqlite.dllphp_pgsql.dllphp_shmop.dllphp_snmp.dllphp_soap.dllphp_sockets.dllphp_sodium.dllphp_sqlite3.dllphp_sysvshm.dllphp_tidy.dllphp_xsl.dllphp_zend_test.dllphp_zip.dll
以上文件作为扩展文件加入
;zend_extension=opcache;扩展文件extension=php_bz2.dllextension=php_com_dotnet.dllextension=php_curl.dllextension=php_dba.dllextension=php_dl_test.dllextension=php_enchant.dllextension=php_exif.dllextension=php_ffi.dllextension=php_fileinfo.dllextension=php_ftp.dllextension=php_gd.dllextension=php_gettext.dllextension=php_gmp.dllextension=php_imap.dllextension=php_intl.dllextension=php_ldap.dllextension=php_mbstring.dllextension=php_mysqli.dllextension=php_oci8_19.dllextension=php_odbc.dllextension=php_opcache.dllextension=php_openssl.dllextension=php_pdo_firebird.dllextension=php_pdo_mysql.dllextension=php_pdo_oci.dllextension=php_pdo_odbc.dllextension=php_pdo_pgsql.dllextension=php_pdo_sqlite.dllextension=php_pgsql.dllextension=php_shmop.dllextension=php_snmp.dllextension=php_soap.dllextension=php_sockets.dllextension=php_sodium.dllextension=php_sqlite3.dllextension=php_sysvshm.dllextension=php_tidy.dllextension=php_xsl.dllextension=php_zend_test.dllextension=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.confD:\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.soLoadModule rewrite_module modules/mod_rewrite.so#LoadModule sed_module modules/mod_sed.so
3、在文件末尾添加如下设置。
#php8LoadModule 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,可以看到如下的效果:
说明
其中,目录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服务,否则修改不生效。至此,所有配置结束。
来源地址:https://blog.csdn.net/SmallWalnutBG/article/details/130022520