search
HomeBackend DevelopmentPHP Tutorial Windows上配置PHP环境

Windows上配置PHP环境

Jun 13, 2016 pm 01:07 PM
apachemysqlphpphpmyadminwindows

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
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 and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 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.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 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.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 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.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

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

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

How does PHP handle object cloning (clone keyword) and the __clone magic method?How does PHP handle object cloning (clone keyword) and the __clone magic method?Apr 17, 2025 am 12:24 AM

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP vs. Python: Use Cases and ApplicationsPHP vs. Python: Use Cases and ApplicationsApr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor