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