Home  >  Article  >  php教程  >  Ubuntu14.04搭建LAMP环境,ubuntu14.04搭建lamp

Ubuntu14.04搭建LAMP环境,ubuntu14.04搭建lamp

WBOY
WBOYOriginal
2016-06-13 09:27:24809browse

Ubuntu14.04搭建LAMP环境,ubuntu14.04搭建lamp

安装Apache2                                                            

<span>sudo</span> apt-get <span>install</span> apache2

 安装PHP模块                                                          

<span>sudo</span> apt-get <span>install</span> php5

 安装Mysql                                                              

<span>sudo</span> apt-get <span>install</span> mysql-<span>server
</span><span>sudo</span> apt-get <span>install</span> mysql-client

 其他模块安装                                                         

sudo apt-get install libapache2-mod-php5
sudo apt-get install libapache2-mod-auth-mysql
<span>sudo</span> apt-get <span>install</span> php5-mysql
<span>sudo</span> apt-get <span>install</span> php5-gd

测试Apache是否正常工作                                      

打开浏览器,输入localhost,看看是否有It Works!网页展示。目录为/var/www

修改权限/var/www                                                 

<span>sudo</span> chomod <span>777</span> /var/www

安装phpmyadmin                                                  

<span>sudo</span> apt-get <span>install</span> phpmyadmin

安装过程中选择apache2,点击确定。下一步选择是要配置数据库,并输入密码。

测试phpmyadmin                                                

<span>sudo</span> <span>ln</span> -s /usr/share/phpmyadmin /var/www

然后直接运行http://localhost/phpmyadmin,看有没有数据库管理软件出现。

配置过程                                                                

第一步 启用mod_rewrite模块

<span>sudo</span> a2enmod rewrite

 重启Apache服务器:

<span>sudo</span> /etc/init.d/apache2 restart或者sudo service apache2 restart

第二步 设置Apache支持.htm .html .php

<span>sudo</span> gedit /etc/apache2/apache2.conf&
添加以下句子:AddType application/x-httpd-php .php .htm .html

第三步 测试php网页

编辑mysql_test.php代码如下
<?<span>php
</span><span>$link</span> = <span>mysql_connect</span>("localhost", "root", "password"<span>);
</span><span>if</span>(!<span>$link</span><span>)
</span><span>die</span>('Could not connect: ' . <span>mysql_error</span><span>());
</span><span>else</span>
<span>echo</span> "Mysql 配置正确!"<span>;
</span><span>mysql_close</span>(<span>$link</span><span>);
</span>?>
访问 http://localhost/mysql_test.php 显示’Mysql 配置正确‘就代表配置正确。

第四步 第三步这里出现了乱码以后解决方法

打开配置文件
<span>sudo</span> gedit /etc/apache2/apache2.conf&

 添加如下代码:AddDefaultCharset UTF-8

到此为止配置OK。

我是天王盖地虎的分割线                                          

 

 

参考:http://blog.csdn.net/callmeback/article/details/8130190

 

怎测试ubuntu服务器版本中LAMP环境是否搭建成功

apache比较好测试,成功之后用浏览器访问localhost会看到It works!
php可以用phpinfo();或者php探针测试,建议去找个探针放在服务器上,以后也用得着,无双城堡的就不错
mysql建议用phpmyadmin,也是建议用完了留在服务器上,管理和备份mysql非常方便
 

LAMP环境搭建,Linux版本选Ubuntu Server与CentOS哪个好点

CentOS明显稳定一点,网上教程也多。
 

Statement:
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