ubuntu lamp(apache+mysql+php) 环境搭建及相关扩展更新

一、环境安装
1.安装apache2
sudo apt-get install apache2
安装后在浏览器中打开:http://localhost/或者http://127.0.0.1
如果出现It works!证明apache安装成功。
2.安装PHP
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
测试:
sudo vi /var/www/testphp.php
写入php works!保存退出vi。
然后在浏览器中输入http://127.0.0.1/testphp.php或者http://localhost/testphp.php
如果显示出php works!表示php配置成功。
3.安装MYSQL
sudo apt-get install mysql-server
安装过程中按提示设置root密码即可。
注:修改密码:
mysql -uroot -p
mysql>use mysql;
mysql>update user set password=PASSWORD('new password') WHERE user='root';
mysql>exit
重启mysql,或是刷新权限也行
重启即可: sudo /etc/init.d/mysql restart 或是 restart mysql
4、让apache、php支持mysql
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo /etc/init.d/apache2 restart
至此Ubuntu+apache2+php 5+mysql的安装完成。
提示:
/etc/apache2/下:
1、apache2.conf 是主配置文件,httpd.conf 用户配置文件
2、虚拟目录在 httpd.conf 中
DocumentRoot “路径”
ServerName 名称
#Listen 127.0.0.1:80 #注意这个文件中不能写上监听,如果必须要写,那就需要先去apache2.conf下将include /etc/apache2/ports.conf 给注释掉,因为ports.conf中已经监听来80端口
3、目录设置在 /etc/apache2/sites-enabled/000-default 可以设置虚拟主机
4、php.ini: /etc/php5/apache2/php.ini
5、mysql.cnf: /etc/mysql/my.cnf
4、重启apache : /etc/init.d/apache2 restart
5、重启mysql: sudo /etc/init.d/mysql restart 或是 restart mysql
6、日志文件: /var/log/apache2/
二、GD库安装
sudo apt-get install php5-gd
sudo /etc/init.d/apache2 restart
三、curl扩展安装
sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart