Home Backend Development PHP Tutorial Windows上配置PHP环境

Windows上配置PHP环境

Jun 13, 2016 pm 01:07 PM
apache mysql php phpmyadmin windows

Windows下配置PHP环境

phpnow在Windows下配置环境很是方便,但是兼容并不是很好,有些时候我们还需要手动在Windows配置PHP环境,手动配置又很麻烦经常忘记配置步骤。所以今天特意记录配置过程。

首先我们需要下载:

apache的官方下载地址:

http://httpd.apache.org/download.cgi

mysql官方下载地:

http://dev.mysql.com/downloads/mysql/5.0.html#win32

php官方下载地址:http://www.php.net/downloads.php

phpMyAdmin官方下载地址:http://phpmyadmin.com/

?

所需软件我们是下载完了,接下来我要安装,点击apache_2.0.59-win32-x86-no_ssl.msi,apache默认端口我们选择80,还有就是不要和IIS得端口号有冲突。与普通应用程序安装

和类似。程序安装完后,我们在浏览器中输入:http://127.0.0.1就可以看到标题写着安装Apache测试页面,表示我们得apache安装成功。

?

Mysql安装:

我们运行mysql文件夹下的Setup.exe。其中有需要设置密码一步,一般建议密码不要为空(如:我们把密码设置成123456)。接着点击下一步,接着是Finish。我们的数据库也安装完毕了。

?

PHP安装配置:

我们把php-5.2.3-Win32.zip解压到C盘根目录下,把文件夹名字改成PHP,这样方便一下。找到PHP目录下的“php.ini-dist”或者“php.ini-recommended”文件,我们把它从命名为"php.ini",复制到“C:\WINDOWS”下。

在将php目录下得php5ts.dll复制到“C:\WINDOWS\system32”目录下。

将php\ext目录下的“php_gd2.dll”与“php_msql.dll”复制到“C:\WINDOWS\system32”目录下。

修改apache的httpd.conf:找到E:\Apache2\conf下得“httpd.conf”文件(最好事先备份一下)。

找到DocumentRoot,把它修改成你网站得根目录,如“DocumentRoot "E:/Apache2/htdocs"”;

查找DirectoryIndex index.html index.html.var 在后面加入index.php

查找#LoadModule ssl_module modules/mod_ssl.so 令起一行加入LoadModule php5_module c:\php\php5apache2.dll;

查找AddType application/x-gzip.gz.tgz后面加入一行AddType application/x-httpd-php.php;

写一个文件index.php,加入""放到apache的根目录下,从起apache服务器,在浏览器中输入:http://126.0.0.1/index.php, 看到php的配置信息,php版本,表示php配置成功.

?

mysql配置:

打开c:\windows\php.ini文件;

查找;extension=php_mysql.dll,去掉';'注释;

查找;extension=php_gd2.dll,去掉';'注释;

查找;extension=php_mbstring.dll,去掉';'注释;

查找;session.save_path="/temp",去掉";",把"/temp"修改成"C:\WINDOWS\Temp";

查找;extension_dir修改为extension_dir="c:\php\ext";

将 libmysql.dll复制到"c:\windows\system32"目录下

查找;extension=php_mysql.dll,去掉';'注释;

重启apache服务器即可.

?

安装配置phpMyAdmin:

把phpMyAdmin解压到apache根目录下(E:\apache\hotdocs),修改E"\apache\htdocs\phpMyAdmin\config.inc.php文件,设置用户名,密码(我们在安装mysql的时候设置过的用户名和密码).在浏览器中输入http://127.0.0.1/phpMyAdmin/ ,即可很方便的管理我们的数据库了.

?

配置apache的虚拟目录:

打开C:\WINDOWS\system32\drivers\etc\hosts文件,添加127.0.0.1 ceshi.com

打开E:\apache\htdocs\httpd.conf文件

找到#NameVirtualHost *:80,去掉"#";

?

ServerAdmin nide@gmail.com //你的邮箱

DocumentRoot E:/www/web //你的虚拟路径地址

ServerName ceshi.com //虚拟路径网址

ErrorLog logs/dummy-host.ceshi.com-error_log

CustomLog logs/dummy-host.ceshi.com-access_log common

?

如果需要设置多个虚拟路径只需要复制改成自己需要的内容即可.

Statement of this Website
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

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The Continued Use of PHP: Reasons for Its Endurance The Continued Use of PHP: Reasons for Its Endurance Apr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

See all articles