mysql.php
apache 默认情况下仅支持html页面,不支持php的页面,php会以模块的方式存在于apache中,安装此模快即可访问php页面。apache通过php调用mysql中的数据。安装lamp:
# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
# yum install httpd php php-mysql mysql mysql-server –y
启动http和mysql
# /etc/init.d/httpd start
Starting httpd: [ OK ]
# /etc/init.d/mysqld start
添加数据库:
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql> use test
Database changed
mysql> create table wu (name char(10),tel char(20),address char(100));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into wu values ('xiaobai','13800138000','bj');
Query OK, 1 row affected (0.00 sec)
mysql>
将mysql.php放到/var/www/html/中
# cd /var/www/html/
# ls
mysql.php
配置mysql.php
# vim mysql.php
http://blog.运维网.com/attachment/201301/210541207.jpg
重启http服务
# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
#
在浏览器中进行测试:
http://192.168.18.167/mysql.php
http://blog.运维网.com/attachment/201301/210510114.jpg
页:
[1]