Build Apache+Mysql+PHP development environment under windows
要求
-
必备知识
熟悉基本编程环境搭建。
-
运行环境
windows 7(64位);
Apache2.2;
MySQL Server 5.5
php-5.3 -
下载地址
环境下载
官方下载地址
- Apache
- MySql
- PHP
至于我使用的版本已经上传到百度云提供大家下载了,这里就不多啰嗦了!!
Apache
Apache的安装和普通的应用程序安装没什么太大的区别,关键是配置。打开安装路径下的"conf\httpd.conf"文件,该文件就是我们Apache的配置文件了。
让Apache支持PHP
LoadModule php5_module "D:/wamp/php-5.3.25/php5apache2_2.dll"<span> AddType application</span>/x-httpd-php .php PHPIniDir "D:/wamp/php-5.3.25/"
配置文件中代码位置如下:
检查WEB根目录是否正确
DocumentRoot "E:/2015/wamp/Apache2.2/htdocs"
让Apache识别index.php页面
<ifmodule dir_module><span> DirectoryIndex index.html index.php </span></ifmodule>
测试Apache是否搭建成功
MySql
关于MySql的安装,这里就不做介绍了!网上教程也比较多。是在不会的童鞋,我已经到网上转载了两篇过来,请点击下边链接进行查看。
- MySQL5.5.21安装图解
- MySQL 5.6安装及配置详细图解
测试Mysql
在DOS窗口中输入如下指令登入Mysql
mysql -u[用户名] -p[密码]
Mysql的一些简单操作指令
<span>//</span><span>连接MYSQL</span> mysql -h主机地址 -<span>u用户名 -p用户密码 </span><span>//</span><span>修改密码</span> mysqladmin -u用户名 -<span>p旧密码 password 新密码 #显示命令 </span><span>//</span><span>显示当前数据库服务器中的数据库列表:</span> mysql><span> SHOW DATABASES; </span><span>//</span><span>显示数据库中的数据表:</span> mysql><span> USE 库名; mysql</span>><span> SHOW TABLES; </span><span>//</span><span>显示数据表的结构:</span> mysql> DESCRIBE 表名;
PHP
将压缩文件解压到指定的文件夹(这里你爱咋整就咋整,下边提供一下我的目录结构),php可以以两种方式运行:CGI(对应文件php5ts.dll文件)和SAPI方式。由于我们使用Apache,所以是以SAPI模块方式运行,对应文件是php5apache2_2.dll。配置php.ini文件,php提供了两个模板,php.ini-development和php.ini-production,前者适合开发程式使用(测试用),后者拥有较高的安全性设定,则适合上线当产品使用。这里我们将php.ini-development文件改为php.ini做配置文件使用。
修改扩展dll文件目录:
<span>//</span><span>这里根据自己的实际情况而定</span> extension_dir = "E:\2015\wamp\php-5.3\ext"
将doc_root设为服务器根路径:
<span>//</span><span>更具个人实际情况而定</span> doc_root ="E:\2015\wamp\Apache2.2\htdocs"
加入扩展:
选择需要运行哪些扩展,只需将extension前面的注释去掉,例如:
extension=<span>php_mysql.dll extension</span>=php_mysqli.dll
测试安装结果
在服务器根路径下建立 phpinfo.php文件,代码如下:
<?php <span>phpinfo(); ?>
浏览器输入http://localhost/phpinfo.php. 出现如下界面则成功。
如以上文章或链接对你有帮助的话,别忘了在文章结尾处轻轻点击一下 “还不错”按钮或到页面右下角点击 “赞一个” 按钮哦。你也可以点击页面右边“分享”悬浮按钮哦,让更多的人阅读这篇文章。
作者:Li-Cheng
微博:http://weibo.com/licheng0426
出处: http://www.cnblogs.com/Li-Cheng/p/4381797.html
由于本人水平有限,文章在表述和代码方面如有不妥之处,欢迎批评指正。留下你的脚印,欢迎评论哦。你也可以关注我,一起学习哦!
(^_^)如果您觉得此文对您有帮助的话,打个赏喝个咖啡吧,么么哒(^_^)
以上就介绍了windows下搭建Apache+Mysql+PHP开发环境,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Reasons for PHPSession failure include configuration errors, cookie issues, and session expiration. 1. Configuration error: Check and set the correct session.save_path. 2.Cookie problem: Make sure the cookie is set correctly. 3.Session expires: Adjust session.gc_maxlifetime value to extend session time.

Methods to debug session problems in PHP include: 1. Check whether the session is started correctly; 2. Verify the delivery of the session ID; 3. Check the storage and reading of session data; 4. Check the server configuration. By outputting session ID and data, viewing session file content, etc., you can effectively diagnose and solve session-related problems.

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Configuring the session lifecycle in PHP can be achieved by setting session.gc_maxlifetime and session.cookie_lifetime. 1) session.gc_maxlifetime controls the survival time of server-side session data, 2) session.cookie_lifetime controls the life cycle of client cookies. When set to 0, the cookie expires when the browser is closed.

The main advantages of using database storage sessions include persistence, scalability, and security. 1. Persistence: Even if the server restarts, the session data can remain unchanged. 2. Scalability: Applicable to distributed systems, ensuring that session data is synchronized between multiple servers. 3. Security: The database provides encrypted storage to protect sensitive information.

Implementing custom session processing in PHP can be done by implementing the SessionHandlerInterface interface. The specific steps include: 1) Creating a class that implements SessionHandlerInterface, such as CustomSessionHandler; 2) Rewriting methods in the interface (such as open, close, read, write, destroy, gc) to define the life cycle and storage method of session data; 3) Register a custom session processor in a PHP script and start the session. This allows data to be stored in media such as MySQL and Redis to improve performance, security and scalability.

SessionID is a mechanism used in web applications to track user session status. 1. It is a randomly generated string used to maintain user's identity information during multiple interactions between the user and the server. 2. The server generates and sends it to the client through cookies or URL parameters to help identify and associate these requests in multiple requests of the user. 3. Generation usually uses random algorithms to ensure uniqueness and unpredictability. 4. In actual development, in-memory databases such as Redis can be used to store session data to improve performance and security.

Managing sessions in stateless environments such as APIs can be achieved by using JWT or cookies. 1. JWT is suitable for statelessness and scalability, but it is large in size when it comes to big data. 2.Cookies are more traditional and easy to implement, but they need to be configured with caution to ensure security.


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

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor
