redflag5.0安装Apache+MySQL+PHP实录

来源:互联网 发布:加入淘宝客要多少钱 编辑:程序博客网 时间:2024/05/22 02:22

Linux配置APACHE2.2.4 + PHP5.2.1 + MYSQL5.0.37 + GD库

第一步:安装RedFlag Linux5.0
安装系统时请务必安装开发工具包和KDE开发工具包,WWW服务器和SQL服务器不要安装,否则可能会出现未知的错误。
第二步:确定linux系统是否安装gcc编译器
首先,GCC要有,不然什么都不能做.可以用gcc -v来查看是否安装了GCC,
#gcc -v
gcc version x.x.x
有以上类似信息说明已有GCC,
如果你没有,请先装好它
第三步:请下载以下所有的东西
httpd-2.2.4.tar.gz
MySQL for redflag rpm:
 mysql-4.1.10a-1.RHEL4.1.i386.rpm
 mysql-bench-4.1.10a-1.RHEL4.1.i386.rpm
 mysqlclient10-3.23.58-4.RHEL4.1.i386.rpm
 mysqlclient10-devel-3.23.58-4.RHEL4.1.i386.rpm
 mysql-devel-4.1.10a-1.RHEL4.1.i386.rpm
 mysql-python-1.0.0-1.RHEL4.1.i386.rpm
 mysql-server-4.1.10a-1.RHEL4.1.i386.rpm
 perl-DBD-mysql-2.9004-3.1.i386.rpm
php-5.2.3.tar.gz
  *libxml2-2.6.11.tar.gz
   *zlib-1.2.1.tar.gz
  *libpng-1.2.5.tar.gz
   *gd-devel-1.8.4-11.i386.rpm
   *libmcrypt-2.5.7.tar.gz
jpegsrc.v6b.tar.gz
可能你的电脑不需要这么多.但最好都下载吧.

检测你的系统是否安装以上的包:
打开终端:
查询是否安装php rpm -q php 或者
查询与php相关联的包 rpm -qa php
若有会显示:version x.x.x  等等
我的系统是:redflag5.0 for dell oem
带*号的为系统自带,若你的系统未安装,先安装吧!

第四步:安装MYSQL 服务器
直接安装rpm包
rpm -ivh somesoft.rpm
启动服务器:
终端输入: /etc/rc.d/init.d/mysqld start
关闭服务器:
终端输入: /etc/rc.d/init.d/mysqld stop
登入:mysql -u mysql
         mysql -uusername -pyoupassword;
mysql>show databases;
最初只有两个:test,information_schema;
以root身份登入则有四个。
运行命令bin/mysql -u root -p,此时将出现password:(要求输入密码),但默认情况下root用户没有密码,所以回车即可。此时将进入MySQL界面,当然仍然只是个命令行窗口而以。
运行命令use test,将进入test数据库
mysql>use test;
mysql> show tables
    -> ;
Empty set (0.00 sec)
建立一个地址簿数据库:
mysql> create database address;
mysql> use address;
Database changed
创建表:
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
ERROR1064 (42000): You have an error in your SQL syntax; check the manualthat corresponds to your MySQL server version for the right syntax touse near 'create table friends (name Char(15),telphone VarChar(20),qqChar(10), address ' at line 1
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
Query OK, 0 rows affected (0.01 sec)

新增几笔资料,并查询看看:
mysql> insert into friends values("xyf","123456","359830463","浙江");
Query OK, 1 row affected (0.00 sec)
mysql> insert into friends values
    -> (
    -> "myblue",
    -> "6743133"
    -> ,"464313113",
    -> "zhejiang");
Query OK, 1 row affected (0.00 sec)
mysql> select * from friends;
+--------+----------+-----------+----------+
| name   | telphone | qq        | address  |
+--------+----------+-----------+----------+
| xyf    | 123456   | 359830463 | 浙江   |
| myblue | 6743133  | 464313113 | zhejiang |
+--------+----------+-----------+----------+
2 rows in set (0.00 sec)
创建和修改密码:
 #在控制台上输入
linux:/usr/local/mysql # bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 18
Server version: 5.1.12-beta MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> update user set password=password('1234') where user='root';
mysql> FLUSH PRIVILEGES; 
mysql> exit
Bye
linux:/usr/local/mysql # bin/mysql -u root -p1234
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 20
Server version: 5.1.12-beta MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
第五步:装GD库支持
安装JPEGSRC
#tar zxvf jpegsrc.v6b.tar.gz
#cd jpegsrc-6b
#./configure
#make
#make install-lib
#make install
第六步:安装PHP5
#tar zxvf php-5.2.1.tar.gz
#cd php-5.2.3
#./configure--prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs--with-jpeg --with-png  --with-gd  --enable-trace-vars --with-zlib--with-mysql 
#make
#make install
第七步:Apache2配置
(1)复制PHP.INI文件到正确位置
在PHP解压的目录下运行
#cp php.ini-dist /usr/local/php/lib/php.ini
(2)编辑apache配置文件httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
要改的有如下几处:

一般都在
#AddType application/x-tar .tgz
下加一行
AddType application/x-httpd-php .php

还有找到
DirectoryIndex index.html index.html.var
在后面加 index.php 让它把index.php做为默认页

再找
#ServerName
把#去掉,后面的IP改成你的IP.

找到
DocumentRoot "/usr/local/apache2/htdocs"
把/usr/local/apache2/htdocs改为你存放网页文件的路径
比如我是放在/myweb目录下,所以我以后上传PHP文件就放在/myweb目录下,然后用IP访问,就能看到首页了
(3)启动Apache2
# /usr/local/apache2/bin/apachectl start
如果没有出错,写一个测试页放到你网页目录下, 我的就是上面所说的 /myweb
在Web根目录下新建test.php
phpinfo();
?>
在浏览器输入:http://127.0.0.1/test.php 如果能看到php的logo标志就说明配置正确了!

原创粉丝点击