一 安装
1 安装apache2 : sudo apt-get install apache2
安装路径: /etc/apache2
apache配置文件: /etc/apache2/apache2.conf
Apache模块路径: /usr/sbin/apachectl
网站目录: /var/www/html
启动路径apache: /etc/init.d/apache2 restart | stop | start
2 安装PHP5: sudo apt-get install libapache2-mod-php5 php5 php5-mysql
安装路径: /etc/php5
php的配置文件:/etc/php5/apache2/php.ini
3 安装mysql: sudo apt-get install mysql-server mysql-client
安装路径: /usr/share/mysql
mysqldump文件位置: /usr/bin/mysqldump
mysql配置文件: /etc/mysql/my.cnf
mysql数据目录在: /var/lib/mysql
mysql 日志文件在: /var/log/mysql
b: 从所有主机:GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password' WITH GRANT OPTION;
c: 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
(2)查看字符编码:mysql> show variables like 'character_set_%';
修改字符编码,例如:mysql> set character_set_database=utf8;
(3)为了方便管理mysql,安装navicat for mysql
a: 解压
b: 进入解压后目录,运行 ./start_navicat
c: 破解: 进入/home/chaosi/.navicat/文件夹,删除system.reg
4 安装phpMyAdmin: sudo apt-get install phpmyadmin
安装路径: /usr/share/phpmyadmin
注: 终端运行sudo apt-get install phpmyadmin,会自动安装在/usr/share/phpMyAdmin下,然后将phpMyAdmin拷贝到/var/www/html目录下面,运行http://localhost/phpMyAdmin即可
5 修改apache默认网站目录
(1) sudo gedit /etc/apache2/sites-available/000-default.conf
(2) 将 DocumentRoot /var/www/html 改为 /home/chaosi/Workspace/web
(3) 换行,加上下面一段话:
<Directory "/home/chaosi/Workspace/web">
Order allow,deny
Allow from all
Require all granted
</Directory>
二 测试
1 测试apache: http://localhost
2 测试php: 在web目录下新建testphp.php内容是:
<?php
phpinfo();
?>
然后:http://localhost/testphp.php
3 测试mysql:在web目录下新建testmysql.php内容是:
<?php
$conn=mysql_connect("localhost","root","ssbb");
if($conn){
echo "连接数据库成功 Success";
}else{
echo "连接数据库失败 Failed";
}
?>
然后:http://localhost/testmysql.php
4 测试phpMyAdmin: http://localhost/phpmyadmin
1 安装apache2 : sudo apt-get install apache2
安装路径: /etc/apache2
apache配置文件: /etc/apache2/apache2.conf
Apache模块路径: /usr/sbin/apachectl
网站目录: /var/www/html
启动路径apache: /etc/init.d/apache2 restart | stop | start
2 安装PHP5: sudo apt-get install libapache2-mod-php5 php5 php5-mysql
安装路径: /etc/php5
php的配置文件:/etc/php5/apache2/php.ini
3 安装mysql: sudo apt-get install mysql-server mysql-client
安装路径: /usr/share/mysql
mysqldump文件位置: /usr/bin/mysqldump
mysql配置文件: /etc/mysql/my.cnf
mysql数据目录在: /var/lib/mysql
mysql 日志文件在: /var/log/mysql
注:(1)允许root远程登陆:
先别忘了sudo gedit /etc/myysql/my.conf 把bind=127.0.0.1注释掉
a: 本机登陆mysql:mysql -u root -p;填密码;改变数据库:use mysql;b: 从所有主机:GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password' WITH GRANT OPTION;
c: 进mysql库查看host为%的数据是否添加:use mysql; select * from user;
(2)查看字符编码:mysql> show variables like 'character_set_%';
修改字符编码,例如:mysql> set character_set_database=utf8;
(3)为了方便管理mysql,安装navicat for mysql
a: 解压
b: 进入解压后目录,运行 ./start_navicat
c: 破解: 进入/home/chaosi/.navicat/文件夹,删除system.reg
4 安装phpMyAdmin: sudo apt-get install phpmyadmin
安装路径: /usr/share/phpmyadmin
注: 终端运行sudo apt-get install phpmyadmin,会自动安装在/usr/share/phpMyAdmin下,然后将phpMyAdmin拷贝到/var/www/html目录下面,运行http://localhost/phpMyAdmin即可
5 修改apache默认网站目录
(1) sudo gedit /etc/apache2/sites-available/000-default.conf
(2) 将 DocumentRoot /var/www/html 改为 /home/chaosi/Workspace/web
(3) 换行,加上下面一段话:
<Directory "/home/chaosi/Workspace/web">
Order allow,deny
Allow from all
Require all granted
</Directory>
二 测试
1 测试apache: http://localhost
2 测试php: 在web目录下新建testphp.php内容是:
<?php
phpinfo();
?>
然后:http://localhost/testphp.php
3 测试mysql:在web目录下新建testmysql.php内容是:
<?php
$conn=mysql_connect("localhost","root","ssbb");
if($conn){
echo "连接数据库成功 Success";
}else{
echo "连接数据库失败 Failed";
}
?>
然后:http://localhost/testmysql.php
4 测试phpMyAdmin: http://localhost/phpmyadmin