LAMP环境搭建(Ubuntu)

LAMP(Ubuntu)环境配置

ubuntu下架构LAMP环境

一、安装apache

1. 命令:$sudo apt-get install apache2

然后运行apache服务器

命令:$sudo /etc/init.d/apache2 restart

apache默认的开发文档的根目录是/var/www/,只要在浏览器中输入

http://localhost/就能看到it works字样,否则安装出现问题,或则www

文件夹下没有index.html文件

2. 配置apache

终端使用命令打开配置文件apache2.conf

$sudo gedit /etc/apache2/apache2.conf


在配置文件中加入一下代码:

添加文件类型支持:

AddType application/x-httpd-php .php .htm .html

添加默认字符集:

AddDefaultCharset UTF-8

服务器地址:

ServerName 127.0.0.1

添加首页文件:

DirectoryIndex index.htm index.html index.php

3. 修改开发文档的根目录

默认根目录是/var/www,正常修改应该是在apache2.conf中的DocumentRoot,但是在ubuntu上的apache2.conf配置文件中没这

个变量,但是在apache2.conf中包含了一句Include sites-enabled/

所以我们到这个文件中去找,发现一个000-default文件,打开里面就可以

设置默认一个DocumentRoot变量,修改到你想要的地方就可以勒。(提示:

DocumentRoot以及Directory标签中的地址)


二、安装PHP

命令:$sudo apt-get install libapache2-mod-php5


三、安装MySQL数据库

命令:$sudo apt-get install mysql-server mysql-client


四、安装phpmyadmin

1. 命令:$sudo apt-get install phpmyadmin

 

2. 配置phpmyadmin

1) 先安装相关的软件包,命令:

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

2) phpmyadmin中的apache2.conf文件复制到apache2

$cp /etc/phpmyadmin/apache.conf /etc/apache2/sites-available/phpmyadmin

3) 进入sites-enabled文件夹下

$cd /etc/apache2/sites-enabled/   

4) 建立一个通往配置文件的链接

$sudo ln -s ../sites-available/phpmyadmin   


5)重启apache2

$sudo /etc/init.d/apache2 restart


OK,到这里LAMP环境的基本配置就结束了,自己去体验吧。

 

posted @ 2013-03-28 21:18  boyz  阅读(307)  评论(0编辑  收藏  举报