搭建PHP建站环境
PHP是一种网站后端脚本语言,通常在web开发中使用apache+PHP+MYSQL这种黄金搭档来建立支持PHP的站点,PHP运行环境或者说任何技术的运行环境都不是简单的加法,即使是安装有apache+PHP+MYSQL的环境也不能正确运行PHP,还要做一些配置工作,网上很多教程只讲如何做这些配置,却不讲为什么这么配置。这导致许多新手在糊里糊涂地情况下编程,对于深入理解构成障碍。而我的文章恰恰相反,我只讲为什么这么配置和安装,至于具体的配置和安装过程,请自行百度。
首先独立的安装PHP的运行环境apache+PHP+MYSQL。在这个过程中需要注意两点:(1)php解压就安装了,php.ini-development与php.ini-production无意义,只有php.ini有意义,二择一(2)apache的安装有dos安装和msi界面安装两种,两者的区别是有无安装引导界面,安装后通过运行bin下的ApacheMonitor.exe来开启apache
PHP的运行原理本质上是浏览器与web服务器之间的通信,浏览器提交请求,web服务器收到请求后将任务交给对应的程序处理,如PHP解释器,MYSQL数据库等,待任务处理完后,web服务器收集处理后的结果并返回给浏览器。所以apache只是相当于管家的角色,并没有实际处理能力,故它需要调用PHP解释器,MYSQL数据库等程序帮忙。apache通过一个模块调用php,这个模块(通常由PHP程序提供)可以是php5apache2_2,模块上清楚的标明了php与apache匹配的版本,所以事先应该下载apache与php兼容的版本。修改apache的配置文件即可实现apache调用php的衔接,配置操作可以简单概括为一句话:就是说明【什么情况下】【调用什么模块】【处理什么】。
以上过程完成了PHP的运行环境,另外还要安装PHP的开发环境,一个php expert editor就够了,它是一个带请求的编辑器,可以理解为记事本+浏览器。写好PHP代码点击运行,就可以看到运行结果,但软件本身并没有PHP运行能力,只不过是向apache发出“请处理PHP”的请求而已。打开IDE的run的option,选择外部apache服务器地址,就可以实现IDE调用apache的衔接。
所有步骤完成之后别忘了测试网站,新手往往忙活了半天,却发现网站无法访问,这主要是没有把墙拆掉的缘故。首先更改防火墙,允许别人接入自己的服务器;再者如果有路由器,要做端口映射。
事实上,上面所有的过程完全可以不做,现在互联网在线开发运行环境异军突起,只要注册一个帐号,打开对应的web在线环境即可学习编程,不过我并不赞成学生这样做,自己动手搭建环境,会对web,PHP的运行原理有深入的理解;而一味的只使用别人封装好的东西,只会让我们成为代码工人。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...
