简体   繁体   English

在Windows上安装PHP,MySql和Apache

[英]Installing PHP, MySql and Apache on windows

Its my first time working with Apache,PHP,MySql. 这是我第一次使用Apache,PHP,MySql。 I downloaded and installed the latest package of these 3. Now I checked with apache and the index.html works. 我下载并安装了这些最新的软件包3.现在我用apache检查了index.html的工作原理。 Now I replaced the index.html with some php script to check if my php works or not. 现在我用一些PHP脚本替换index.html来检查我的php是否有效。 When opened the html page again I see the php code directly. 当再次打开html页面时,我直接看到了php代码。 It seems it does not work. 它似乎不起作用。 following is how my php code looks like. 以下是我的PHP代码的样子。

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

when I open my index.php , I see the above code itself. 当我打开index.php时,我看到上面的代码本身。 Can anybody let me know whats wrong and how can i fix it? 任何人都可以告诉我什么是错的,我该如何解决?

Check your apache httpd.conf file for some commented out code that looks like this 检查你的apache httpd.conf文件中是否有一些看似这样的注释掉的代码

LoadModule php5_module libexec/apache2/libphp5.so

and further down the file, this... 并进一步下载文件,这......

<IfModule php5_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    <IfModule dir_module>
            DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

it seems there is some problem in the installation. 似乎安装中存在一些问题。 use WAMP as stefan and dessus or XAMPP. 使用WAMP作为stefan和dessus或XAMPP。 i recomand u to use XAMPP its bundled with APACHE, MYSQL, File Zilla Server, Mercury for mail. 我重新尝试使用与APACHE,MYSQL,File Zilla Server,Mercury捆绑在一起的XAMPP邮件。 Easy to Install and Use . 容易安装,也容易使用 。 http://www.apachefriends.org/en/xampp.html http://www.apachefriends.org/en/xampp.html

Another vote for WampServer. 对WampServer的另一次投票。 Once you have a working server, it's then easier to poke around with configurations files and then learn Apache/PHP configuration that way. 一旦你有了一个正常工作的服务器,就可以更容易地使用配置文件,然后以这种方式学习Apache / PHP配置。

use wamp! 用wamp! it's easy and fast :) 它简单快捷:)

http://www.wampserver.com/en/ http://www.wampserver.com/en/

personally, i use an old version from 2007, 1.7.4, it can be found here: http://sourceforge.net/projects/wampserver/files%2FWAMP5/ 就个人而言,我使用了2007年的旧版本1.7.4,可以在这里找到: http//sourceforge.net/projects/wampserver/files%2FWAMP5/

the good thing about using an old version is that your code will work on old machines, and many servers out there have old versions of php and mysql. 使用旧版本的好处是你的代码可以在旧机器上运行,许多服务器都有旧版本的php和mysql。

the bad thing about using an old version is that your code might not work on new machines, and some machines out there have new versions of php and mysql. 使用旧版本的坏处是你的代码可能无法在新机器上运行,而且有些机器有新版本的php和mysql。

http://computing-know.blogspot.in/#!/2013/10/how-to-setup-apache-php-mysql.html http://computing-know.blogspot.in/#!/2013/10/how-to-setup-apache-php-mysql.html

Step By Step Process to Setup Apaache,PHP,Mysql,phpMyAdmin and XDebug. 一步一步的过程来设置Apaache,PHP,Mysql,phpMyAdmin和XDebug。

1)How to install Apache 1)如何安装Apache

2)Setup PHP for Apache 2)为Apache设置PHP

3)Install & Configure MySQL to use with PHP 3)安装和配置MySQL以与PHP一起使用

4)Setup XDebug for Debugging 4)设置XDebug进行调试

5)phpMyAdmin 5)phpMyAdmin的

Note:In this tutorial my Server Folder is located on F:\\Server 注意:在本教程中,我的服务器文件夹位于F:\\ Server上

How to install Apache 如何安装Apache

1)There are two ways to install apache either install the old version of apache httpd (Compatible with Windows XP) from httpd.apache.org/download.cgi or get the latest apache build zip from www.apachelounge.com/download/ . 1)有两种方法可以安装apache,或者从httpd.apache.org/download.cgi安装旧版本的apache httpd(与Windows XP兼容),或者从www.apachelounge.com/download/获取最新的apache build zip。

2)I will show how to configure apache from the zip version downloaded from apachelounge.com/download/ . 2)我将展示如何从apachelounge.com/download/下载的zip版本配置apache。

3)Click on Additional + VC9 on the left of the page. 3)单击页面左侧的Additional + VC9。

4)Download the 2.4.x zip build with OpenSSL 0.9.8. 4)使用OpenSSL 0.9.8下载2.4.x zip版本。

5)Create a folder with a name Server on location where . 5)在位置创建名称为Server的文件夹。

6)My Location is F:\\Server 6)我的位置是F:\\ Server

7)Extract the Apache24 from apache zip to the Server folder. 7)将Apache24从apache zip解压缩到Server文件夹。

8)Now Goto config folder in Apache and open httpd.config in any text editor. 8)现在转到Apache中的配置文件夹,并在任何文本编辑器中打开httpd.config。

9)Find(Ctrl + F) and replace each and every instance of "c:/Apache24" and change it to your apache location in my case its f:/Server/Apaache24. 9)找到(Ctrl + F)并替换“c:/ Apache24”的每个实例,并将其更改为您的apache位置,例如f:/ Server / Apaache24。

ServerRoot "c:/Apache24" with ServerRoot "f:/Server/Apache24" ServerRoot“c:/ Apache24”与ServerRoot“f:/ Server / Apache24”

DocumentRoot "c:/Apache24/htdocs" with DocumentRoot "f:/Server/Apache24/htdocs" DocumentRoot“c:/ Apache24 / htdocs”与DocumentRoot“f:/ Server / Apache24 / htdocs”

with

ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/" with ScriptAlias /cgi-bin/ "f:/Server/Apache24/cgi-bin/" ScriptAlias / cgi-bin /“c:/ Apache24 / cgi-bin /”与ScriptAlias / cgi-bin /“f:/ Server / Apache24 / cgi-bin /”

with

8)Now run the Command Prompt (with Administrator Rights) . 8)现在运行命令提示符(具有管理员权限)。

9)On Command Prompt go to the location Server/Apache24/bin . 9)在命令提示符上转到Server / Apache24 / bin位置。

10)Inside the Bin folder type "httpd -k install" to install the Apache service and then press Enter. 10)在Bin文件夹中输入“httpd -k install”以安装Apache服务,然后按Enter键。

11)To start the Apache Server simply type in "httpd -k start" and then press Enter. 11)要启动Apache Server,只需键入“httpd -k start”,然后按Enter键。

12)Restart Your Computer 12)重新启动计算机

13)Now Open the Bin folder and double click on the ApacheMonitor.exe and Start Apache 13)现在打开Bin文件夹,双击ApacheMonitor.exe并启动Apache

14)Now Goto localhost if you see page "It Works" then Apache is sucessfully installed on you computer. 14)现在转到localhost如果你看到“It Works”页面,那么Apache已成功安装在你的计算机上。

If you see a page that says "It works!" 如果您看到一个页面上写着“它有效!” then the Apache server has been installed successfully. 然后Apache服务器已成功安装。

Setup PHP for Apache 为Apache设置PHP

1)Goto windows.php.net/download/ download the php-5.4.x-Win32-VC9-x86.zip. 1)转到windows.php.net/download/下载php-5.4.x-Win32-VC9-x86.zip。

2)Create a folder named php inside Server folder. 2)在Server文件夹中创建一个名为php的文件夹。

3)Extract all files from php-5.4.x-Win32-VC9-x86.zip to php folder in the Server. 3)将所有文件从php-5.4.x-Win32-VC9-x86.zip解压缩到服务器中的php文件夹。

4)Now Goto config folder in Apache and open httpd.config in any text editor. 4)现在转到Apache中的配置文件夹,并在任何文本编辑器中打开httpd.config。

5)Find(Ctrl + F) the LoadModule scroll down until last LoadModule and Paste the following 5)找到(Ctrl + F)LoadModule向下滚动,直到最后一个LoadModule并粘贴以下内容

LoadModule php5_module "f:/Server/php/php5apache2_4.dll". LoadModule php5_module“f:/Server/php/php5apache2_4.dll”。

6) Find(Ctrl + F) the AddType scroll down until last AddType and Paste the following 6)找到(Ctrl + F)AddType向下滚动,直到最后一个AddType并粘贴以下内容

AddType application/x-httpd-php .php . AddType application / x-httpd-php .php。

7)Add the PHP location to the end of the httpd.conf file. 7)将PHP位置添加到httpd.conf文件的末尾。 For example, at the end of the file, add the following: PHPIniDir "Your PHP Location". 例如,在文件末尾添加以下内容:PHPIniDir“您的PHP位置”。

localhost/info.php 本地主机/ info.php的

8)In the php folder rename the php.ini-development to php.ini and open it in Text Editor. 8)在php文件夹中将php.ini-development重命名为php.ini并在Text Editor中打开它。

9)Find(Ctrl + F) the display_errors, and make sure the value is set to On. 9)找到(Ctrl + F)display_errors,并确保将值设置为On。

10) Find(Ctrl + F) the extension_dir = "./" and change it to extension_dir = "F:\\Server\\php\\ext" . 10)找到(Ctrl + F)extension_dir =“./”并将其更改为extension_dir =“F:\\ Server \\ php \\ ext”。

11)Restart Apache Server. 11)重启Apache服务器。

12)Create a file "phpinfo.php" in htdocs folder in Apache with follwoing content: 12)在Apache的htdocs文件夹中创建一个文件“phpinfo.php”,其中包含以下内容:

13)Goto localhost/phpinfo.php 13)转到localhost / phpinfo.php

extension_dir = "./" extension_dir =“./”

14)Right Click MyComputer Click Propertes 14)右键单击MyComputer单击属性

15)Click Environment Variables 15)单击Environment Variables

16)Add Your php folder location at the end of the path 16)在路径末尾添加php文件夹位置

17)Restart Your Computer. 17)重新启动计算机。

Install & Configure MySQL to use with PHP 安装和配置MySQL以与PHP一起使用

1)Goto dev.mysql.com/downloads/mysql/ download the zip or installer version. 1)转到dev.mysql.com/downloads/mysql/下载zip或安装程序版本。

2)Install MySQL 2)安装MySQL

3)Click Next 3)单击“下一步”

4)Select Complete & click Next 4)选择Complete并单击Next

5)Click Finsh 5)单击Finsh

6)Click Standard Configuration 6)单击“标准配置”

7)Click Next 7)单击“下一步”

8)Enter the password for mySQL 8)输入mySQL的密码

9)Goto MySQL Command Line and enter the password. 9)转到MySQL命令行并输入密码。

12)Open the php.ini file and find the line: ;extension=php_mysql.dll remove the semi-colon. 12)打开php.ini文件并找到以下行:; extension = php_mysql.dll删除分号。

and find the line: ;extension=php_mysql.dll 并找到行:; extension = php_mysql.dll

phpMyAdmin phpMyAdmin的

1)Goto config folder in Apache and open httpd.config in any text editor. 1)转到Apache中的config文件夹,在任何文本编辑器中打开httpd.config。

2) Find(Ctrl + F) the line DirectoryIndex index.html add index.php. 2)找到(Ctrl + F)行DirectoryIndex index.html添加index.php。

3)Open php.ini file in the Server Folder and Uncomment the mbstring and mysqli extension. 3)在服务器文件夹中打开php.ini文件并取消注释mbstring和mysqli扩展。

3)Goto phpmyadmin.net/ Download the latest phpMyAdmin-4.0.8-english.zip. 3)转到phpmyadmin.net/下载最新的phpMyAdmin-4.0.8-english.zip。

4)Extract it to phpMyAdmin folder in htdocs. 4)将其解压缩到htdocs中的phpMyAdmin文件夹。

5)Restart the Apache Server. 5)重新启动Apache服务器。

6)Goto localhost/phpMyAdmin/ 6)转到localhost / phpMyAdmin /

Setup XDebug for Debugging 设置XDebug进行调试

1)Goto http://xdebug.org/download.php from your browser and download the 1)从浏览器转到http://xdebug.org/download.php并下载

php_xdebug-2.xx-5.4-vc9 Thread Safe 32 bit version. php_xdebug-2.xx-5.4-vc9线程安全32位版本。

2)Copy and Paste it to the extension folder in the php. 2)复制并粘贴到php中的扩展文件夹。

3)Copy & Paste the following line of code at the end of php.ini file . 3)在php.ini文件的末尾复制并粘贴以下代码行。

[XDebug] [了XDebug]

;; ;; Only Zend OR (!) XDebug 只有Zend OR(!)XDebug

zend_extension="Your Location of Xdebug" zend_extension =“你在Xdebug的位置”

xdebug.remote_enable=true xdebug.remote_enable =真

xdebug.remote_host=localhost xdebug.remote_host =本地主机

xdebug.remote_port=10000 xdebug.remote_port = 10000

xdebug.remote_handler=dbgp xdebug.remote_handler = dbgp

4)Restart Apache Server. 4)重启Apache服务器。

5)Goto to localhost/phpinfo.php scroll down to see if xDebug is installed 5)转到localhost / phpinfo.php向下滚动以查看是否安装了xDebug

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM