win7Apache
今天第一次尝试搭建了一个php的开发环境,软件使用了 php-5.4.29,apache2.4,MySql5.5。
Apache 的官方下载( http://httpd.apache.org/download.cgi )并没有提供 2.4 的 Windows 版本,而是提供了 Unix 下的 tar.bz2 和 tar.gz 安装包,这两个在windows下是不能用的。
Apache版本: httpd-2.4.9-win32-VC11.zip
下载地址 http://www.apachelounge.com/download/
Php版本: php-5.4.29-Win32-VC9-x86.zip
下载地址:http://windows.php.net/downloads/releases/
Mysql版本:mysql server 5.5 这个mysql是J2EE时一直在用的Mysql版本
下载地址:http://dev.mysql.com/downloads/installer/5.5.html
Apache2.4.9安装
1、下载解压修改参数
解压包中目录中,VC11是运行时,win7应该有自带。没有的话下载安装即可。
官方建议将Apache24文件夹解压到C:/根目录,我不想在C盘下放太多东西,就改在了D盘我的软件文件夹中了,我的路径是D:/Software Files/Apache24,如果更改了默认路径,那么下边需要修改几个位置路径参数即可。 打开 Apache/conf/httpd.conf 文件,建议用编辑工具打开,修改以下内容:
1)37行 ServerRoot "D:/Software Files/Apache24"
2)374行
3)358行 ScriptAlias /cgi-bin/ "D:/Software Files/Apache24/cgi-bin/"
即这些路径均将C盘的默认路径改为自己的路径,一定注意这里的斜杠方向。
4)241、242行(这里是站点的根目录,放入这里的php文件可以访问到)改为
DocumentRoot "D:/Software Files/Apache24/htdocs" 和
2、启动Apache
- 1)打开cmd,路径进入自己的apache路径的bin文件夹下,我的是D:/Software Files/Apache24/bin,之后输入httpd.exe -k install,将Apache安装为系统服务,安装成功后Apache会自行测试80端口是否可用。
- 2)双击bin下的ApacheMoniter.exe,打开Apache管理器,看看指示灯是红的还是绿的,如果是绿的说明安装成功并启动了,如果是红的,则再点start应该就能变绿了。
- 这里如果遇到不能启动的问题,在cmd中刚刚同样位置下输入 httpd.exe -k start 这样启动的话,如果报错将会显示出是刚刚我们修改的那个conf文件中第几行路径有错,改正后应该就没有问题了。
- 3)打开浏览器,URL中输入http://localhost,发现出现了一个大大的“It works!”即配置成功。
Php配置
1、下载解压
将下载的php解压到自己的路径下,我的是 D:/Software Files/php-5.4.29,之后找到php.ini-development文件,直接复制一份在旁边,并改名为php.ini。2、配置php.ini
1 )找到“ ; extension_dir = "ext" ”,在它下面添加如下代码:
; 指定 PHP 扩展库的路径
extension_dir = "F:/Program Files/PHP/ PHP-5.4.5/ext"
2 )找到“ ;extension=php_gd2.dll ”、“ ;extension=php_mysql.dll ”、“;extension=php_mysqli.dll ”去掉前面的“ ; ”
这是在开启 PHP 对图形化和 MySQL 的支持。
3 )保存并关闭。
3、配置httpd.conf
1 )在文件末尾添加如下代码,各行代码的意思应该都说明的很清楚了:
# 载入 PHP 处理模块
LoadModule php5_module "F:/Program Files/PHP/ PHP-5.4.5/php5apache2_4.dll"
# 指定当资源类型为 .php 时,由 PHP 来处理
AddHandler application/x-httpd-php .php
# 指定 php.ini 的路径
PHPIniDir "F:/Program Files/PHP/ PHP-5.4.5"
# 其他相关设置
AddHandler application/x-httpd-php-source .phps
Action application/x-httpd-php "/php/php-cgi.exe"
AddDefaultCharset UTF8
2 )保存并关闭。
4、配置系统环境变量
1 )打开系统属性→高级→环境变量
2 )在系统变量下新建,变量名为 PHP_HOME ,变量值为 PHP 的解压目录,我的是F:/Program Files/PHP/ PHP-5.4.5 。
3 )系统变量的 Path 编辑,在末尾加上 %PHP_HOME%;%PHP_HOME%/ext;
5、测试是否整合成功
1 )利用之前的小羽毛重启 Apache 。
2 )在站点根目录 WebContent 下新建 index.php ,填入如下代码:
<?php phpinfo();?>
保存。
3 )在浏览器地址栏输入 http://localhost/index.php ,出现:

安装及配置MySql
mysql的安装及用户名密码配置等就不再说了。 测试时
1)编写连接 MySQL 的 PHP 代码
在 htdocs下新建文件 testConn.php ,填入如下代码,注意文件格式保存为 UTF-8 ,否则是乱码:
<?php $conn = mysql_connect("localhost", "root", "admin"); if ($conn) { echo "连接MySQL数据库成功"; } else { echo "连接MySQL数据库失败"; }?>
2)浏览器地址栏输入 http://localhost/testConn.php
如果出现“连接 MySQL 数据库成功”,那么说明 AMP 环境已经搭建成功,可以进入开发阶段了;如果出现“连接 MySQL 数据库失败”,请检查 MySQL 服务是否已启动;如果出现“ Fatal error: Call to undefined function mysql_connect() ...... ”,请检查是否完全按照二中的 2 配置了php.ini 。

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.

MySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

Atom editor mac version download
The most popular open source editor

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software