


Complete configuration of PHP APACHE MYSQ under windows_PHP tutorial
经过最近一段时间狂热的PHP编程,对WINDOWS平台下PHP的配置可算是深有感触,一开始我用的是一键安装的傻瓜包,但是考虑傻瓜包的安装版本已经落后,在真正手动配置PHP环境时遇到许多问题,在查阅了许多资料和尝试后,终于配置成功。现在,我将我的配置经验和大家分享一下,相信可以解决大家配置PHP环境的迷惑。
首先说一下我用的软件版本。
PH
APACHE
MYSQL
好了,现在开始安装,我先装的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.dll
到这里php.ini就配置结束。接着很重要的一点将
C:\PHP\libmysql.dll,C:\PHP\ext\php_mysql.dll,C:\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.x和4.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!

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.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

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 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 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 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.

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

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.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools