Linux · 2009-04-23

centos上安装apache2+mysql5.0+php5

yum安装软件包:
yum install httpd php mysql mysql-server php-mysql

启动mysql
/etc/init.d/mysqld start

为root设置mysql的密码
mysqladmin -u root password ‘你要设置的密码’

用刚才设置的密码登陆
mysql -u root -p

显示数据库
mysql> show databases;

删除测试数据库
mysql> DROP DATABASE test;
Query OK, 0 rows affected (0.00 sec)

删除匿名用户
mysql> DELETE FROM mysql.user WHERE user = ”;
Query OK, 0 rows affected (0.00 sec)

刷新数据库
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

启动apache
/etc/init.d/httpd start

让重启或断电后,机器启动后自动开启http与mysql服务
/sbin/chkconfig httpd on
/sbin/chkconfig –add mysqld
/sbin/chkconfig mysqld on
/sbin/service httpd start
/sbin/service mysqld start

进到这个目录
[root@localhost html]# pwd
/var/www/html

web访问,测试看php能否看到信息.
[root@localhost html]# cat hi.php

[root@localhost html]# ls -lh
total 4.0K
-rw-r–r– 1 root root 20 Apr 23 03:24 hi.php