php自学教程
1、PHP环境搭建的前提是 Apache HTTP Server (Apache 服务器)已经安装部署成功,并可以正常访问到服务器的主页面Apache HTTP Server 的安装部署资源网已经在上一篇讲解的很详细了,不清楚的可以点击“ Apache HTTP Servcer-Apache服务器下载与Windows系统下安装”查看具体操作。
2、PHP下载: 2.1、下载地址:http:/资源网/php.net/downloads.php 2.1、版本选择:如果是与 Apache 搭配,建议选择 Thread Safe 版本;如果是与 CGI 或者 FAST-CGI 搭配,建议选择 Non 资源网Thread Safe 版本。
3、PHP环境搭建: 3.1、将下载的 .zip 压缩包解压到指定的安装目录,此处安装路径为:D:\solt\php_5.6.33 3.2、将 PHP 的根目录下的 ph资源网p.ini-development 或者 php.ini-production复制一份并改名为 php.ini,作为PHP的配置文件;。
3.3、打开php.ini,修改配置信息: 说明:a、ini文件资源网的注释是分号(英文分号),所以取消注释就删除分号; b、${phphome}是PHP的根目录,即:D:\solt\php_5.6.33,配置文件中写成绝对路径。
3.3.1、修改扩展文件的路径:; ex资源网tension_dir = "ext" 取消注释,或者改为: extension_dir = "${phphome}\ext";注意:如果是与 Apache 搭配,建议将扩展文件路径改为绝对路径,因为资源网有可能加载不了。
3.3.2、修改需要加载的扩展文件,下面代码是取消部分扩展程序的注释之后的代码:extension=php_bz2.dllextension=php_curl.dllextension资源网=php_fileinfo.dll
extension=php_gd2.dllextension=php_gettext.dll;extension=php_gmp.dll;extension=php_资源网intl.dll;extension=php_imap.dll
;extension=php_interbase.dll;extension=php_ldap.dllextension=php_mbst资源网ring.dllextension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dllex资源网tension=php_mysqli.dll;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
exten资源网sion=php_openssl.dll;extension=php_pdo_firebird.dllextension=php_pdo_mysql.dll;extension=php_pdo_oci资源网.dll
extension=php_pdo_odbc.dllextension=php_pdo_pgsql.dllextension=php_pdo_sqlite.dllextension=php_p资源网gsql.dll
;extension=php_shmop.dll; The MIBS data available in the PHP distribution must be installed.资源网 ; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dllextension=php_soap.d资源网llextension=php_sockets.dllextension=php_sqlite3.dll;extension=php_sybase_ct.dll
extension=php_tidy.d资源网llextension=php_xmlrpc.dllextension=php_xsl.dll 3.3.3、设置默认的时区:[Date]; Defines the default timezone u资源网sed by the date functions
; http://php.net/date.timezone 选择时区列表网址date.timezone = Asia/Shanghai 3.3.4、资源网设置 ssl :[openssl]; The location of a Certificate Authority (CA) file on the local filesystem
; to use资源网 when verifying the identity of SSL/TLS peers. Most users should; not specify a value for this direc资源网tive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value资源网 may still; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.openssl.资源网cafile= cacert.pem 根据需求可以自己添加扩展 3.4、修改 Apache24\conf\ 目录下的 httpd.conf 配置 Apache ,让 Apache 和 PHP 协同工作资源网;。
3.4.1、DocumentRoot 设置: 修改前:默认的是 Apache24 下的 htdocs 目录: 修改后:指定到自定义的路径,但是要记住这个路径 3.4.2、修改默认的索引,以支持 P资源网HP :。
修改前:# DirectoryIndex: sets the file that Apache will serve if a directory# is requested.#
Direct资源网oryIndex index.html 修改后:# DirectoryIndex: sets the file that Apache will serve if a directory
# is re资源网quested.# DirectoryIndex index.html index.php index.htm 3.4.3、开启 rewrite 功能:将下面这行代码前面的 # 去掉:
LoadModu资源网le rewrite_module modules/mod_rewrite.so 3.4.4、加载 PHP 模块,注意绝对路径: 如果是 PHP 5,在 httpd.conf 文件最后添加如下代码:
#资源网php5.6LoadModule php5_module D:/soft/php-5.6.33/php5apache2_4.dll PHPIniDir "D:/soft/php-5.6.33/"
Add资源网Type application/x-httpd-php .php AddType application/x-httpd-php-source .phps 如果是 PHP 7,则相应的更改,示例如下资源网:
#php7LoadModule php7_module D:/soft/php-7.x.x/php7apache2_4.dll PHPIniDir "D:/soft/php-7.x.x/"
AddTy资源网pe application/x-httpd-php .php AddType application/x-httpd-php-source .phps 3.5、如果安装的PHP x64位版本,Apa资源网che也需要是x64位版本的。
然后还要将php目录下的libeay32.dll、ssleay32.dll、libssh2.dll以及ext目录下的php_curl.dll等四个文件,都复制放到Syst资源网em32目录下否则curl扩展无法使用。
参考链接:http://my.oschina.net/lsfop/blog/496181 未做验证,只是照做,正常显示4、Apache + PHP 启动运行测试资源网: 4.1、在 D:\soft\php_5.6.33\www 目录下,创建 index.php 文件,文本内容如下:。
4.2、重启 Apache 服务,打开浏览地址栏输入: localhost:808资源网1/index.php 或者 127.0.0.1:8081/index.php ,就可以打开 PHP 页面。
最后说明一点儿,PHP 环境搭建可以借助于 PHP 开发环境搭建工具,下载地址:http:/资源网/www.php.cn/xiazai/gongju或者http://www.wampserver.com/,在此处就不介绍工具安装方法了。
原文:https://blog.csdn.net/weixin资源网_39082031/article/details/79110311相关内容:https://study.163.com/course/courseMain.htm?courseId=12104062资源网06&share=2&shareId=480000002227524
亲爱的读者们,感谢您花时间阅读本文。如果您对本文有任何疑问或建议,请随时联系我。我非常乐意与您交流。
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。