windows和Linux环境下php apache mysql 环境的搭建教程
windows和linux环境下php教程 apache mysql教程 环境的搭建教程
详解如何正确配置php开发环境
php语言在进行开发之前,需要将开发环境配置妥当,这样才能实现我们的程序完美运行。那么,如何正确的配置php开发环境呢?文章将介绍apache、mysql、php的下载、安装及配置,分别讲述在windows和linux环境下开发环境的搭建。
一、下载apache、mysql和php
1、apache的下载
apache服务器可以通过官方提供的镜像地址来下载windows的apache安装程序,不过都是英文版的,而且下载速度太慢。我建议大家去华军、天空或者中关村下载最新版的安装程序,速度很快。
2、mysql的下载
mysql的官方网站是http://www.mysql.com。可以下载最新版本的mysql,还是那句话,建议大家去华军、天空或者中关村下载。
3、php的下载
php的官方网站是http://www.php.net。可以下载最新的版本。
二、在windows下配置php开发环境
1、apache、mysql和php的安装像安装windows其他软件一样,这里建议把apache和php软件安装在d盘目录下,把mysql软件安装在c盘,这样不需要做任何设置,mysql就可以顺利启动运行。
2、配置开发环境
为了让windows可以执行php,需要做进一步的工作,按以下步骤搭建好环境:
1)在php安装目录下,找到文件php5ts.dll,将其复制到c盘system32目录下。
2)在php安装目录下,找到文件libmysql.dll,将其复制到c盘system32目录下。
3)在php安装目录下,找到文件php.ini,将其复制到c:windows下。这个文件是配置php的基本文件,如设置服务器根目录配置,用文本编辑器打开php.ini文件,找到"doc_root=",因为我把apache默认安装在d盘根目录下,所以,修改这个配置项的值为:doc_root=d:apache2htdocs
提示:用户根据自己安装apache的路径,修改该配置项的值。
4)在php.ini中找到“extension_dir ="./"”,这个配置项用来载入php的扩展模块,修改该配置项如下:extension_dir = d:phpext,(需要按自己的安装目录修改php的载入位置)。
5)在php.ini中找到“;extension=php_mysql.dll”,把这项前面的分号去掉,表示使这个项生效。这个配置项用来使php支持mysql,这里分号起注释作用。修改完php的配置文件php.ini后,保存退出该文件。
6)进行apache的配置。转到apache的安装目录下的conf目录,用文本编辑器打开apache的配置文件http.conf。在此文件中找到 dynamic shared object(dos) support,在loadmodule行的最后添加如下配置项:loadmodule php5_module d:/php/php5apache2.dll,(需要按自己的安装目录修改php的载入位置)。该项是通过apache来载入php模块php5apache2.dll,即php以apache的一个模块来运行。
7)为了让apache支持.php后缀的文件,在http.conf中找到addtype项,在最后添加如下配置项:addtype application/x-httpd-php.php。找到directoryindex,在最后添加index.php。为了支持中文,找到adddefaultcharset iso-8859-1改为adddefaultcharset gb2312。修改完后保存http.conf。即完成apache的基本配置。
注意:强烈建议对apache配置文件http.conf进行修改时,一定遵守修改一点测试一点的原则,即每次修改完一项并保存http.conf后,要重启一下apache,如果apache正常启动,则可以进行后续修改,否则,说明本次修改有误,仔细检查并重新修改。
三、在linux下配置配置php开发环境
1、mysql的安装
在mysql官网下载mysql的安装文件mysql-server-4.0.20-0.i386.rpm,执行下面的命令完成mysql的安装。
rpm -ivh mysql-server-4.0.20-0.i386.rpm
在没有设置mysql密码的情况下,通过以下命令测试mysql是否安装成功。
mysql -u root
出现类似welcome to the mysql mointor. commands end with;or g的字样,说明安装成功。
2、apache的安装
从apache的官网下载unix版本的压缩包,以httpd-2.0.52.tar.gz为例,假设资源包放在/usr/local/src下,进入这个目录后解压缩,命令如下:
cd /usr/local/src
tar -zxvf httpd-2.0.52.tar.gz
解压缩后,进入目录httpd-2.0.52,执行以下命令:
./configure --prefix=/usr/local/apache2 --enable--module=so
其中--prefix=/usr/local/apache2用来指定apache的安装目录。接下来进行编译,执行一下命令完成安装。
make
mae install
3、配置php开发环境的安装
1)从php官网下载php5.1.4.tar.gz的压缩包,解压缩该文件包,命令如下:
tar -zxf php5.1.4.tar.gz
2)转到解压缩后的目录,执行以下命令完成php安装目录等相关配置:
./configure --prefix=/usr/local/php -with-mysql=/var/lib/mysql
3)接着编译php,命令如下:
make
make install
4)复制当前目录下的文件php大安装目录的lib目录下,并改名为php.ini,命令如下:
cp php.ini-dist /usr/local/php/lib/php.ini
5)以上配置php开发环境的安装完后,参见windows下配置的内容进行相关配置,配置项和配置方法类似。

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



Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

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,

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

How to master Bootstrap customization and component usage includes: 1. Use CSS variables and Sass preprocessor for style customization; 2. Deeply understand and modify component structure and behavior. Through these methods, a unique user interface can be created to improve the responsiveness and user experience of the website.

Using Golang to implement Linux...

Linux is best used as server management, embedded systems and desktop environments. 1) In server management, Linux is used to host websites, databases, and applications, providing stability and reliability. 2) In embedded systems, Linux is widely used in smart home and automotive electronic systems because of its flexibility and stability. 3) In the desktop environment, Linux provides rich applications and efficient performance.
