分类: 系统运维
2013-02-25 11:17:19
基于CentOs5.5版本
必须的套件有,apache(httpd),-server,php,php-devel,php-mysql,安装好套件后
1、httpd的设置(简单的修改一下启动即可,先是最基本的设置,虚拟主机什么的先不设置)
[root@client ~]# vi /etc/httpd/conf/httpd.conf (找到下边的那句话,加入index.php,意思就是可以搜索到.php的网页作为主业)
DirectoryIndex index.html index.html.var index.php
[root@client ~]# /etc/init.d/httpd restart
2、mysql的设置(建立一个数据库,然后在刚建立的数据库中添加一张表,并且插入内容)
[root@client ~]# /etc/init.d/mysqld restart
[root@client ~]# mysqladmin -u root password '721wyzj'(给root加入密码)
[root@client ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database bbs;
Query OK, 1 row affected (0.03 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| laji |
| mysql |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use bbs;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create table message(id int(10),title varchar(20),content varchar(200));
mysql> insert into message values('001','ethnicity','wethnicity');
mysql> select * from message;
+------+-----------+------------------+
| id | title | content |
+------+-----------+------------------+
| 1 | ethnicity | wethnicity |
+------+-----------+------------------+
1 rows in set (0.00 sec)
mysql> quit
Bye
保存退出
[root@client ~]# /etc/init.d/mysqld restart
3、接着是php的设置(用php书写一个简单
的留言板,包含三个页面,连接数据库页面(conn.php),插入数据页面(insert.php),以及读取数据页面(index.php),然后用
ssh工具把页面放到linux的/var/www/html/目录下即可)
conn.php
$conn = @ mysql_connect("localhost", "root", "721wyzj") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names gb2312");
?>
insert.php
include('conn.php');
$sql="insert into message (`id`,`title`,`content`) values
$query=mysql_query($sql,$conn) or die("数据插入失败");
?>
if('$_POST[submit]'){
(' ','$_POST[title]','$_POST[content]')";
}