实验环境:redhat 企业版 5.4
httpd-2.2.19.tar.bz2
mysql-5.5.15-linux2.6-i686.tar.gz
php-5.3.7.tar.bz2
需要的软件
Development Libraries
Development Tools
Legacy Software Development
X Software Development
GNME Software Devleopment
KDE Software Development
确保以上包已被安装
将软件考入管理员家目录下
[root@localhost ~]# ll -h
总计 171M
-rw------- 1 root root 1.2K 02-09 22:23 anaconda-ks.cfg
drwxr-xr-x 2 root root 4.0K 03-18 17:11 Desktop
-rwxrw-rw- 1 root root 5.1M 2011-05-22 httpd-2.2.19.tar.bz2
-rw-r--r-- 1 root root 35K 02-09 22:23 install.log
-rw-r--r-- 1 root root 4.0K 02-09 22:22 install.log.syslog
-rwxrw-rw- 1 root root 155M 2011-07-15 mysql-5.5.15-linux2.6-i686.tar.gz
-rwxrw-rw- 1 root root 11M 2011-08-18 php-5.3.7.tar.bz2
将以上软件分别解压缩
[root@localhost ~]# cd /usr/local/
[root@localhost local]# tar -zxvf /root/mysql-5.5.15-linux2.6-i686.tar.gz
[root@localhost local]# ll
总计 76
drwxr-xr-x 2 root root 4096 2008-08-08 bin
drwxr-xr-x 2 root root 4096 2008-08-08 etc
drwxr-xr-x 2 root root 4096 2008-08-08 games
drwxr-xr-x 2 root root 4096 2008-08-08 include
drwxr-xr-x 2 root root 4096 2008-08-08 lib
drwxr-xr-x 2 root root 4096 2008-08-08 libexec
drwxr-xr-x 13 root root 4096 03-18 17:17 mysql-5.5.15-linux2.6-i686
drwxr-xr-x 2 root root 4096 2008-08-08 sbin
drwxr-xr-x 4 root root 4096 02-09 22:09 share
drwxr-xr-x 2 root root 4096 2008-08-08 src
root@localhost local]# cd src
[root@localhost src]# tar -jxvf /root/httpd-2.2.19.tar.bz2
[root@localhost src]# tar -jxvf /root/php-5.3.7.tar.bz2
[root@localhost src]# ll
总计 8
drwxr-xr-x 11 sun sun 4096 2011-05-21 httpd-2.2.19
drwxr-xr-x 13 1000 1000 4096 2011-08-17 php-5.3.7
配置mysql
[root@localhost src]# cd ../local/mysql-5.5.15-linux2.6-i686/
[root@localhost mysql-5.5.15-linux2.6-i686]# less INSTALL-BINARY
根据提示步骤配置
创建mysql系统账号
[root@localhost mysql-5.5.15-linux2.6-i686]# groupadd mysql
[root@localhost mysql-5.5.15-linux2.6-i686]# useradd -r -M -g mysql mysql
修改mysql目录下的所属组及所属用户
[root@localhost mysql-5.5.15-linux2.6-i686]# chown -R mysql .
[root@localhost mysql-5.5.15-linux2.6-i686]# chgrp -R mysql .
[root@localhost mysql-5.5.15-linux2.6-i686]# ll
总计 76
drwxr-xr-x 2 mysql mysql 4096 03-18 17:16 bin
-rw-r--r-- 1 mysql mysql 17987 2011-07-14 COPYING
drwxr-xr-x 4 mysql mysql 4096 03-18 17:16 data
drwxr-xr-x 2 mysql mysql 4096 03-18 17:17 docs
drwxr-xr-x 3 mysql mysql 4096 03-18 17:16 include
-rw-r--r-- 1 mysql mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 03-18 17:17 lib
drwxr-xr-x 4 mysql mysql 4096 03-18 17:16 man
drwxr-xr-x 10 mysql mysql 4096 03-18 17:16 mysql-test
-rw-r--r-- 1 mysql mysql 2552 2011-07-14 README
drwxr-xr-x 2 mysql mysql 4096 03-18 17:16 scripts
drwxr-xr-x 27 mysql mysql 4096 03-18 17:16 share
drwxr-xr-x 4 mysql mysql 4096 03-18 17:17 sql-bench
drwxr-xr-x 2 mysql mysql 4096 03-18 17:17 support-files
使用mysql用户初始化mysql
[root@localhost mysql-5.5.15-linux2.6-i686]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
将mysql目录下除了data目录的所有者重新改回管理员
[root@localhost mysql-5.5.15-linux2.6-i686]# chown -R root .
[root@localhost mysql-5.5.15-linux2.6-i686]# chown -R mysql data
[root@localhost mysql-5.5.15-linux2.6-i686]# ll
总计 76
drwxr-xr-x 2 root mysql 4096 03-18 17:16 bin
-rw-r--r-- 1 root mysql 17987 2011-07-14 COPYING
drwxr-xr-x 5 mysql mysql 4096 03-18 17:41 data
drwxr-xr-x 2 root mysql 4096 03-18 17:17 docs
drwxr-xr-x 3 root mysql 4096 03-18 17:16 include
-rw-r--r-- 1 root mysql 7604 2011-07-14 INSTALL-BINARY
drwxr-xr-x 3 root mysql 4096 03-18 17:17 lib
drwxr-xr-x 4 root mysql 4096 03-18 17:16 man
drwxr-xr-x 10 root mysql 4096 03-18 17:16 mysql-test
-rw-r--r-- 1 root mysql 2552 2011-07-14 README
drwxr-xr-x 2 root mysql 4096 03-18 17:16 scripts
drwxr-xr-x 27 root mysql 4096 03-18 17:16 share
drwxr-xr-x 4 root mysql 4096 03-18 17:17 sql-bench
drwxr-xr-x 2 root mysql 4096 03-18 17:17 support-files
重做关于内存的配置文件
[root@localhost mysql-5.5.15-linux2.6-i686]# cp support-files/my-large.cnf /etc/my.cnf
在后台启动mysql
[root@localhost mysql-5.5.15-linux2.6-i686]# bin/mysqld_safe --user=mysql &
[1] 8348
[root@localhost mysql-5.5.15-linux2.6-i686]# 120318 17:57:55 mysqld_safe Logging to '/usr/local/mysql-5.5.15-linux2.6-i686/data/localhost.localdomain.err'.
120318 17:57:55 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.5.15-linux2.6-i686/data
查看监听端口,表示已经启动成功
[root@localhost mysql-5.5.15-linux2.6-i686]# netstat -utpln|grep mysql
tcp
0 0 :::3306 :::* LISTEN 8412/mysqld
设置启动配置文件
[root@localhost mysql-5.5.15-linux2.6-i686]# cp support-files/mysql.server /etc/init.d/mysqld
将头文件和库文件连接到系统默认的位置
[root@localhost mysql-5.5.15-linux2.6-i686]# ln -s /usr/local/mysql/include/ /usr/include/mysql [root@localhost mysql-5.5.15-linux2.6-i686]# vim /etc/ld.so.conf.d/mysqld.conf
/usr/local/mysql-5.5.15-linux2.6-i686/lib/
测试是否成功导入
[root@localhost mysql-5.5.15-linux2.6-i686]# ldconfig -v|grep mysql
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
在系统变量插入mysq路径
[root@localhost mysql-5.5.15-linux2.6-i686]# vim /etc/profile
[root@localhost mysql-5.5.15-linux2.6-i686]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin
在chkconfig中添加mysql服务
[root@localhost mysql-5.5.15-linux2.6-i686]# chkconfig --add mysqld
[root@localhost mysql-5.5.15-linux2.6-i686]# chkconfig --list |grep mysqld
mysqld
0:关闭
1:关闭
2:启用
3:启用
4:启用
5:启用
6:关闭
至此可以用 service mysqld 来管理mysqld服务
[root@localhost mysql-5.5.15-linux2.6-i686]# service mysqld status
MySQL running (6571)
[ OK ]
配置apache
[root@localhost mysql-5.5.15-linux2.6-i686]# cd ../src/httpd-2.2.19/
[root@localhost httpd-2.2.19]# ll –h
可以看到有个configure可执行文件,说明该软件包是未编译的原文件
配置安装文件
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-ssl --with-z --enable-so
其中
--prefix=(安装文件目录)
--sysconfdir=(配置文件目录)
--enable-ssl(启用ss)
--with-z(使用特殊的库文件)
编译
[root@localhost httpd-2.2.19]# make
[root@localhost httpd-2.2.19]# make install
启动httpd服务
[root@localhost httpd-2.2.19]# cd /usr/local/apache/
[root@localhost apache]# bin/apachectl start
查看监听端口
[root@localhost apache]# netstat -utpln |grep httpd
tcp
0 0 :::80 :::* LISTEN 29231/httpd
修改环境变量
[root@localhost apache]# vim /etc/profile
重新读取配置文件
[root@localhost apache]# . /etc/profile
查看环境变量
[root@localhost apache]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/usr/local/apache/bin:/root/bin
此时可以直接用
[root@localhost include]# apachectl stop
[root@localhost include]# apachectl start
将头文件和库文件连接到系统默认的位置
[root@localhost apache]# vim /etc/ld.so.conf.d/httpd.conf
/usr/local/apache/lib/
测试是否成功导入
[root@localhost apache]# ldconfig -v|grep apache
/usr/local/apache/lib:
[root@localhost apache]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apache/include/ httpd
[root@localhost include]#
测试apache安装成功
Php
[root@localhost php-5.3.7]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring=all --with-xmlrpc --with-png-dir --with-jpeg-dir --with-zlib --with-gd
其中
--prefix= 指明安装位置
--with-apxs2= 指明调用模块
--with-mysql= 指明mysql
--wtih-mysqli= 指明mysql接口
--enable-mbstring=all 支持的字符集
--with-xmlrpc 支持xml
--with-png 支持的图形格式
--with-jpeg 支持的图形格式
--with-zlib
--with-gd 支持压缩
[root@localhost php-5.3.7]#make
[root@localhost php-5.3.7]#make install
[root@localhost php-5.3.7]# cd /usr/local/php/
[root@localhost php]# ll
总计 20
drwxr-xr-x 2 root root 4096 03-19 10:37 bin
drwxr-xr-x 2 root root 4096 03-19 10:37 etc
drwxr-xr-x 3 root root 4096 03-19 10:36 include
drwxr-xr-x 3 root root 4096 03-19 10:36 lib
drwxr-xr-x 3 root root 4096 03-19 10:36 man
修改apache的主配置文件
[root@localhost php]#vim /etc/httpd/httpd.conf
重启apache服务
[root@localhost php]# apachectl stop
[root@localhost php]# apachectl start
编辑一个测试页
[root@localhost php]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# mv index.html index.php
[root@localhost htdocs]# vim index.php
测试php成功
重新编辑页面测试mysql是否连接成功
[root@localhost htdocs]# vim index.php
测试mysal连接成功