Home > php教程 > php手册 > 手把手教你在Ubuntu上安装Apache、MySql和PHP

手把手教你在Ubuntu上安装Apache、MySql和PHP

WBOY
Release: 2016-06-13 11:14:28
Original
1030 people have browsed it

1:首先安装apache:打开终端(ctrl+Alt+t),

输入命令:sudo apt-get install apache2即可安装,

安装完后,打开浏览器,在地址栏输入:localhost或者http://127.0.0.1

看到It works,表示安装成功!

默认根目录:/var/www/

2:安装mysql:

sudo apt-get install mysql-server-5.0

安装完后,会要你新设置mysql root密码,输入你自己的密码后enter键,再确认密码。

3:安装PHP 5 and Apache PHP 5 module:

sudo apt-get install php5 libapache2-mod-php5

sudo /etc/init.d/apache2 restart(重启apache)

试试成功否:

命令:gksudo gedit /var/www/text.php 【在apache默认根目录/var/www/下创建一text.php文件】

在text.php文件中输入以下代码检验是否安装成功:

<ol class="dp-xml">
<li class="alt"><span><span class="tag"></span><span class="tag-name">php</span><span>   </span></span></li>
<li><span>echo “helloworld”;   </span></li>
<li>
<span> </span><span class="tag">?></span><span>  </span>
</li>
</ol>
Copy after login

在浏览器地址栏输入:http://localhost/text.php 如果页面显示helloworld则表示成功

温馨提示:如果返回终端时无法再次输入命令时,按ctrl+z组合键

4:让apache和php支持php :

sudo apt-get install libapache2-mod-auth-mysql

sudo apt-get install php5-mysql

sudo /etc/init.d/apache2 restart(重启apache)

至此环境已搭建完!

/var/www/(apache2网页文件放在这里)

/var/lib/mysql(mysql文件放在这里)

如果你要远程连接的话,还要安装SSH,命令:sudo apt-get install ssh

可能我们还是习惯用phpmyadmin

5:安装phpmyadmin

sudo apt-get install phpmyadmin

此时在浏览器上输入:http://localhost/phpmyadmin 发现not found

所以我们还必须把安装好到phpmyadmin文件夹转移到/var/www/下面

sudo ln -s /usr/share/phpmyadmin/ /var/www/

执行上面到命令,我们已经把phpmyadmin文件夹转移到目的地了,也或者你把phpmyadmin直接复制到/var/www/的文件夹下面也可以。

我们再次浏览器上输入:http://localhost/phpmyadmin 回车时发现我们熟悉的界面回来了

原文:http://blog.csdn.net/guaikai/article/details/6905781


source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template