Table of Contents
PHP开发环境&MySQL下载安装及配置流程
Home php教程 php手册 PHP开发环境&MySQL下载安装及配置流程

PHP开发环境&MySQL下载安装及配置流程

Jun 06, 2016 pm 07:53 PM
amp mysql php download Install develop flow environment Configuration

PHP开发环境MySQL下载安装及配置流程 因工作需要,从0开始学PHP,前几天看完视频教程后开始搞开发环境,到今天才好。这里把安装配置流程梳理一下分享出来。 一、概述 要搭建一个开发环境无非就是这么几步,下载-安装-配置。PHP的环境需要三样东西,php、mysq

PHP开发环境&MySQL下载安装及配置流程

    因工作需要,从0开始学PHP,前几天看完视频教程后开始搞开发环境,到今天才好。这里把安装配置流程梳理一下分享出来。

一、概述

<span>要搭建一个开发环境无非就是这么几步,下载->安装->配置。PHP的环境需要三样东西,php、mysql、</span><span>apache(按</span><span>序如下图)</span><span>,按照我的理解,它们分别是语言解释器、数据库、</span><span>服务器</span><span>。</span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

二、下载

<span>PHP100.com是个神奇的网站,我从这上面找到了前两样东西的下载地址,apache的链似乎坏了,官网上也找不到下载位置就去网上搜了一个。下面给出这三个东西的下载地址。</span>
Copy after login

http://windows.php.net/downloads/releases/php-5.4.31-Win32-VC9-x86.zip
http://10.224.254.1/files/7228000000C5A56E/cz.jz123.cn:898/soft/mysql-5.5.28-win32.zip
http://www.crsky.com/soft/1368.html#down
Copy after login

三、安装

<span>下载完了就开始安吧</span>
Copy after login

(1)php:这是一个绿色软件,解压到指定位置就可以,无需多说。

(2)apache:再来安apache。

PHP开发环境&MySQL下载安装及配置流程

<span>第一处值得一说的地方在这里。上两个框分别代表网络域名和服务器名,随便一写,后面也没有用到过。下面的radiobutton选80就可以,不过要是你的80端口被其它程序占了就要选8080了。</span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span>Typical是默认,Custom是自定义,这里默认即可。</span>
Copy after login
<span>安装完后可以看见屏幕右下角<img  src="/static/imghw/default1.png" data-src="/inc/test.jsp?url=http%3A%2F%2Fimg.blog.csdn.net%2F20140726224911151&refer=http%3A%2F%2Fblog.csdn.net%2Fblogs_of_slicer%2Farticle%2Fdetails%2F38151315" class="lazy" alt="PHP开发环境&amp;MySQL下载安装及配置流程" >这样一个图标,表示apache已启动了。</span>
Copy after login

(3)mysql

PHP开发环境&MySQL下载安装及配置流程
<span>Typical即可,然后安装部分就没什么好说了,安装完后即刻配置。</span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span>细节配置or标准配置?选择细节配置(Detailed Configuration)</span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span>开发者模式or服务器模式orMysql专用服务器模式?专业程度递增,性能递增,占用资源也是递增的,如果是开发者自己搞,建议选Developer Machine</span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span>第二个是只支持事务性的数据库,适合作应用的数据库或交互性较强的网站;
</span><span>第三个是只支持非事务性的数据库,适合简易的web应用、监控或日志应用还有分析程序;
</span><span>第一个是以下两种都支持,选这个。</span>
Copy after login
PHP开发环境&MySQL下载安装及配置流程
<span><span>这一页是选服务器的最大连接数。第一个固定最大20,第二个最大500,第三个自选。</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span>这一页不用动,除非你3306端口已经被占了。</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span>选字符集(charset),决定往数据库中存的数据用什么编码格式,我选的gb2312</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>这里要注意一下,强烈建议把第二个复选框选上,这样你就能从cmd黑框里执行mysql命令了。其它不用动。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span>创建初始用户,第一个是创建root用户,设计一个密码就可以;第二个是创建匿名用户,也就是说,你的数据库可以不用用户名密码直接登录,安全起见不建议选这一项。另外,确认密码下面那个选项是说允许远程连接的用户使用root的账号密码登陆,视情况而定吧。</span>
Copy after login

四、配置

(1)httpd.conf

先来配置apache吧,在apache2.2目录下找到一个conf的文件夹,里面有一个叫做httpd.conf的文件,这是apache的配置文件,要让apache支持php,就从这里开始了。打开这个.conf文件,从上往下顺着说
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>ServerRoot这一行记着你apache的安装位置,如果需要移走的话,移动完之后改一下这里就可以;下面Listen 80意思是监听的80端口,之前安装时选过,可以在这里改。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>最关键的地方在这里,php解压完后目录下会有一个php5apache2_2.dll文件,把加在php模块的语句写在这里(如上图),apache就能支持php了。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>就如同用eclipse写java程序要先指定一个WorkSpace一样,这里的DocumentRoot就相当于一个WorkSpace目录,默认htdocs。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>向下不远,Directory后引号里的目录代表系统向apache授予搜索权限的目录,所以上面的工作空间(WorkSpace)必须要是这里这个目录的子目录(或一样)才行。这里这个目录可以写的大一点,我就选了D盘根目录。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>这里DirectoryIndex指的是到了WorkSpace下先找newfile.php如果没有,去找index.php,还没有再找index.html。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>这里这两行第一行是添加一个文件类型的识别,添加后apache就认识扩展名是.php的文件了;下面PHPIniDir给出的是php的ini配置文件的路径,下面还要提到这个文件。</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>这里这几种错误值得一提。Error500是系统内部脚本错误,指网页里跑的程序出错,Error404是找不到指定网页的错误</span></span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span><span>这里的Virtual Host是虚拟主机,把“#”去掉释放这句可以开启虚拟主机。如果不用虚拟主机的话,只能在地址栏输入localhost然后apache去找工作空间里Directory Index指定的文件名,用虚拟主机的话可以同时指定多个地址对应多个目录,如果需要调试的文件较多且不放在一处的情况下,使用虚拟主机是一个不错的选择。</span></span></span>
Copy after login

(2)httpd-vhost.conf

如果开启了虚拟主机,就要配置这个文件了,这个文件在conf目录下的extra目录下。

PHP开发环境&MySQL下载安装及配置流程

<span><span>这是我的配置情况(部分)。在地址栏输入ServerName的内容,apache就会去DocumentRoot的地址去找网页内容。如果想让多个ServerName对应一个目录,可以把别的ServerName写在ServerAlias里。</span></span>
Copy after login

(3)php.ini

<span><span>下面来进行php的配置,这个文件在php的解压目录下,把php.ini-production和php.ini-development两个文件其中一个的“-”及之后的内容去掉,就变成了ini文件(这是两种模式,生产者和开发者。我去掉的是-production)。打开之</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span>找到这个地方,把如图这些extension前的;去掉</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span>extension_dir 扩展目录路径</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<span><span>default_charset 默认字符集UTF-8</span></span>
Copy after login


<span><span>好了,整个安装配置过程就是这样了,下面是我连上数据库的景象</span></span>
Copy after login

PHP开发环境&MySQL下载安装及配置流程

<?php include ("conn.php");//连接数据库
#$id=str_replace(" ","",$_POST[&#39;id&#39;]);//接收客户端发来的username;
$id=&#39;0001&#39;;
$sql="select * from Student where Stuid=&#39;$id&#39;";
$query=mysql_query($sql);
$rs = mysql_fetch_array($query);
if(is_array($rs)){
	#if($_POST[&#39;pwd&#39;]==$rs[&#39;Stupwd&#39;]){
	if($rs[&#39;Stupwd&#39;]==&#39;abcd&#39;){
		echo "login succeed";
	}else echo "illegal user!";
}else echo "no result found!";

?>
Copy after login


经历了一天多才完全配置成功,如有出入欢迎评论指正。我的配置过程90%是跟着PHP100的视频教程来的,不过他没有讲php.ini这个文件,这个文件我是从网上查到的教程,感谢笨蛋兄

http://www.cnblogs.com/homezzm/archive/2012/08/01/2618062.html





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)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1267
29
C# Tutorial
1240
24
MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

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.

How does MySQL differ from Oracle? How does MySQL differ from Oracle? Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

MySQL: The Database, phpMyAdmin: The Management Interface MySQL: The Database, phpMyAdmin: The Management Interface Apr 29, 2025 am 12:44 AM

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

See all articles