search
HomeBackend DevelopmentPHP Tutorial筹建windows下php环境(一)

搭建windows下php环境(一)
第一次写,不知道如何开头,就把今天搭建php环境的流程梳理一下,以供参考.
先介绍一下运行环境:win7 + Apache 2.4.10 + php 5.5.15 + oracle 11g
先前从php.net和apache.org上下载了最新版本,但是由于都是需要自己编译的,所以还是直接用编译好的。下面是获取介质的地址,不用满处瞎找了。
http://www.apachelounge.com/download/
http://windows.php.net/

剩下的工作就是下载,安装.安装都是直接解压即可。我个人认为解压的东西最好放在某个盘的根目录下,不要太深入了。
剩下就是简单的配置:
1、将PHP的安装目录下的2个php.ini-*的文件,根据自身情况修改php.ini;
2、然后根据需要修改php.ini文件,目前我只搭建了一个基本环境,而且是连接oracle11g,所以现在只修改了一些相关的内容,其他的安全性的配置并没有弄:
添加  extension_dir = "E:/php/php5.5/ext"
将extension=php_oci8_11g.dll和extension=php_pdo_oci.dll前面的;去掉
修改一下时区为中国时区
date.timezone = Asia/Shanghai
3、修改Apache安装目录下的conf文件夹下的httpd.conf文件
  将ServerRoot的值修改为自己的Apache安装目录(例如:"E:/php/Apache24"),这个一定要在注册为windows服务前修改,不然注册时会报错.
  添加下面信息
      PHPIniDir "E:/php/php5.5"
     LoadModule php5_module "E:/php/php5.5/php5apache2_4.dll"
  修改下面的路径为自己网站的目录:
      DocumentRoot "E:/php/web"
    
  寻找AddType,在后面添加如下内容:
  AddType application/x-httpd-php .php .html .htm
4、将Apache注册为windows服务,这样启停比较方便。注意一点,在注册之前,先要
    使用cmd进入Apache的安装目录下的bin文件夹下,执行如下命令:
          httpd -k install  //还可以自定义服务名,这里就不介绍了
    上面基本上搭建完了php和apache环境,能否对外提供服务了,但是还有很多参数需要调整的,后面学习时,再给补充上.下面搭建oracle环境.
   我是在一台设备上安装了oracle数据库,同时安装了一个oracle Instance Client客户端,这个客户端主要是为了OCI等内容.网上的链接好多都不能下载,下面提供一个,目前下载没有问题:
http://www.oracle.com/technetwork/topics/winx64soft-089540.html
oralce数据库的安装文件直接去oracle网站下就行了,这个挺好找的.
   这里略去oracle的安装过程,oracle Instance Client客户端直接解压就可以了,建议也是放在某个盘的根目录下,然后在PATH变量中添加该客户端的路径,而且要放在最前面.如果本机上没有安装oracle数据库,倒是无所谓了.
   安装完客户端,需要重启一下Apache服务.这块注意一下,我在重启的时候,是直接点击的"重启",但是发现Apache安装目录下的log文件夹下的httpd.pid文件的修改时间并没有更新,而且在使用phpinfo();测试的时候,OCI的模块也没有显示出来,很是奇怪,所以这块建议先停止,然后启动.这样就没有出现上面的问题.
   具体原因,我查找了Apache的技术文档中关于重启的集中方式。其中有一种重启,是apache父进程并没有停止,而是把子进程杀掉了.虽然也会重读配置文件和重新生成日志文件.但是模块只会重置状态为初始值,但是对于变化的内容却没有生效.(这块有一些我自己的理解,真正是不是这样还需要进一步确认).
    现在就可以测试了,写一个简单的demo.php页面:

<?php phpinfo();?>

然后在浏览器中的输入http://localhost/demo.php,大功告成.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),