Home Backend Development PHP Tutorial Complete configuration of PHP APACHE MYSQ under windows_PHP tutorial

Complete configuration of PHP APACHE MYSQ under windows_PHP tutorial

Jul 21, 2016 pm 03:58 PM
apache php win windows Down whole right of programming Configuration

经过最近一段时间狂热的PHP编程,对WINDOWS平台下PHP的配置可算是深有感触,一开始我用的是一键安装的傻瓜包,但是考虑傻瓜包的安装版本已经落后,在真正手动配置PHP环境时遇到许多问题,在查阅了许多资料和尝试后,终于配置成功。现在,我将我的配置经验和大家分享一下,相信可以解决大家配置PHP环境的迷惑。

 

首先说一下我用的软件版本。

PHP 5.1.6

APACHE 2.0.59(注意:APACHE 2.2.X版本以上必须安装插件才支持PHP 5)

MYSQL 5.0.24a

 

  好了,现在开始安装,我先装的php5,直接解压文件到C:\php安装到哪里并不会有影响,凭个人喜号,本文中的所有路径都以我的安装路径,请大家在自己的机器上安装的时候注意修改为自己的路径),接着安装APACHE,我直接把它装到C盘根目录下,在安装过程中,会出现3个文本框,上面两个输入你的本机IP,最下面的输入你的EMAIL,好的。安装完毕。现在编辑..\Apache Group\Apache2\conf\下的httpd.conf文件。用记事本打开该文件,在最后添上这两行代码:

LoadModule php5_module "C:/php/php5apache2.dll"
AddType application/x-httpd-php .php

 

  我在C:\目录下建立了一个www的目录用于存放我的站点文件,在httpd.conf里找到这样一句话:DocumentRoot "C:/Apache2/htdocs"改成了DocumentRoot "C:/www"。这样,就将主目录设置成了C:\www。如果你不想更改主目录位置,可以不更改此项。

 

  修改目录的默认首页:
找到DirectoryIndex 后面写上你想设置为首页的文件名,如:index.html index.php等。

 

  语言优先级,找到下列语句

  LanguagePriority zh-CN zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv
把中文(zh-CN zh-TW)的部分剪切放到前面(也就是将原来文件中的相应
部分改成如上的。

 

其他也没什么好改动的。APACH的配置就到这里。接着讲PHP的配置。

 

php.ini-dist复制到C:\windows 下改名为 php.ini(装过php的都做过吧)
然后修改了几个地方:

 

 

Data Handling下找到post_max_size = 8M

这是PHP将接受的POST数据最大大小,可更改为20M

 

Paths and Directories下找到extension_dir=

这里设置的是PHP搜索扩展库的位置,将其路径设为extensions文件夹的位置,即改成:

extension_dir= "C:\php\ext"

 

File Uploads下找到upload_max_filesize = 2M,允许上传的的最大文件大小

可更改为20M

 

Dynamic Extensions
这里是PHP扩展设置部分,列出了PHP所有的可支持扩展,前面都加了分号注
释,表示目前PHP配置不支持扩展,我们可以将分号去掉让PHP支持该扩展
下面列出的是几个常用且较实用的PHP扩展
把下面几句前面的分号去掉

;extension=php_mbstring.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_imap.dll
;extension=php_mysql.dl
l

到这里php.ini就配置结束。接着很重要的一点将

C:\PHP\libmysql.dllC:\PHP\ext\php_mysql.dllC:\PHP\ext\php_mysqli.dll

拷贝到C:\Windows\system32下,这样PHP5才能支持MYSQL

  重起APACHE,在主目录下新建一个记事本文件test在里面输入

phpinfo();

?>

保存后修改后缀名为PHP。在浏览器输入http://127.0.0.1/test.php是不是看到PHP版本信息,没错,这样PHP的配置就完成了。接下来安装MYSQL

 

第一步:双击.exe文件出现的第一个需要选择的对话框是Setup Type 也就是
安装种类,这里我们可以选择Custom,根据自己的需要来安装组件和配置安装路径

点击Next,右键点击对话框出现几个硬盘形状的图标,根据自己的需要选择安装组件,

点击窗口右下的Change按钮更改安装路径的,设置好后,点击Next开始安装安装到最
后会有如下一个对话框在这里的三个选项分别是:

1
:如果你没有MYSQL.com帐户,选第一个,创造一个新的免费的MYSQL.com帐户

2
:如果你有MYSQL.com帐户,选第二个,填入已经注册好的邮箱名和密码

3
:跳过此步骤

我们选第一个

接下来会一次出现三个对话框,在三个对话框中有* 号的部分是必须要填的,
按顺序分别是邮箱名,密码,确认密码;first name last name;邮政编码,
国家,省名。国家名选china,省名选other or N/A即可4.1.x4.0.x系列版
本很大一个区别就是在安装完毕后不是运行 mysql文件夹下面的winmysqladmin.exe
启动服务器后设置选项,而是有一个设置的过程。

第二步:设置MYSQL

首先你会看到这样的一个窗口,这里有两个选项,分别是详细配置和标准配置,

小型应用选第二项就可以了点击Next后出现下面的对话框,这里是重要的,一定
要在下拉菜单里选择MySQL41,否则不能正常启动,下面的选项是是否应用命令行,
最好选上点击Next后设置数据库密码的对话框,中间偏右和下面的选项分别是是否
允许远程控制和是否允许匿名帐号登入,为了安全,不要选择好了,点击Next后出
现最后的对话框,点击Execute按钮数据库服务器便启动了,依次出现四个对号后
点击Finish结束安装

  装上PHPMYADMIN后测试连接,若出现

#1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
开始菜单找到刚刚安装的MYSQL命令行工具,输入root的密码后键入如下的字样:
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD(‘刚才设置的ROOT密码')
-> WHERE Host = 'localhost' AND User = 'root';
mysql> FLUSH PRIVILEGES;(
注意FLUSH后有空格)

然后浏览“http://localhost/phpmyadmin”OH YEAH 测试成功!

 

  在谈一下关于MYSQL 4.1以后由于采用UTF8导致的乱码问题解决办法。首先注意一点,在新建数据库的时候字符集一定要选择UTF8,在PHPMYADMIN中新建数据库下,创建按钮的左边,有个下拉列表,默认是“整理”,选择UTF8。你会发现表里数据不在是问号了。

但是网页的输出还是问号,不要急接着在PHP语句中要有所改动:

mysql_connect(…连接参数);后加上mysql_query("SET NAMES 'GBK'");linux 下GBK改为UTF8

但是如果网页很多,这样不是很麻烦,所以我在编写PHP时将所有数据库的操作写成一个类如:

class db{

.包含一些数据库调用方法….

  //创建数据库连接并选择相应数据库

       function createcon(){

           mysql_connect();mysql_query("SET NAMES 'GBK'");

}

}

In this way, you only need to change one thing. Isn’t it very convenient? Haha, I believe that after reading this article, everyone will realize that the PHP environment is difficult to configure. Okay, I am exhausted from writing so much. I wish you all a happy study!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317707.htmlTechArticleAfter a recent period of enthusiastic PHP programming, I have deep feelings about the configuration of PHP under the WINDOWS platform. At the beginning I use the one-click installation fool package, but consider the installation of the fool package...
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's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 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.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

How to quickly configure CentOS HDFS How to quickly configure CentOS HDFS Apr 14, 2025 pm 07:24 PM

Deploying Hadoop Distributed File System (HDFS) on a CentOS system requires several steps, and the following guide briefly describes the configuration process in stand-alone mode. Full cluster deployment is more complex. 1. Java environment configuration First, make sure that the system has Java installed. Install OpenJDK with the following command: yumininstall-yjava-1.8.0-openjdk-devel Configure Java environment variables: echo "exportJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk">>/etc/profileecho"ex

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

See all articles