ubuntu 下LAMP服务器环境搭建
操作系统: ubuntu14.04 64bit
1、安装 Apache2:
sudo apt-get install apache2
2、安装PHP模块:
sudo apt-get install php5
3、安装Mysql
1)安装mysql服务器:
sudo apt-get install mysql-server
中途会提示输入root密码
2)安装mysql客户端
sudo apt-get install mysql-client
3)mysql启动和重启命令
启动:sudo /etc/init.d/mysql start
关闭:sudo /etc/init.d/mysql stop
重启:sudo /etc/init.d/mysql restart
4)测试mysql是否安装成功
mysql -u root -p
4、其他必须模块安装:
1)apache2 php5模块
sudo apt-get install libapache2-mod-php5
2)apache2 mysql模块
sudo apt-get install libapache2-mod-auth-mysql
3)php5 mysql模块
sudo apt-get install php5-mysql
5、测试apache2是否安装成功:
1)、启动apache2服务器,命令参考附录。
2)、浏览器输入 http://localhost/
PS: 目前情况下,apache默认的www目录为/var/www/html 如果需要更改,参考附录操作
附录:
1、改变apache2的默认目录
apache2的默认目录配置在/etc/apache2/sites-enabled/00default文件中。
找到该文件中的DocumentRoot项: DocumentRoot /var/www/html
将/var/www/html改为你的www目录,重启服务器。
2、apache服务器重启与停止命令
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 end
sudo /etc/init.d/apache2 restart