源代码运用到linux上需要三个步骤:
一
配置
二
编译
三
安装
环境 linux5.3企业版
所用源码及包为
php-5.3.7.tar.bz2
mysql-5.5.15-linux2.6-i686.tar.gz
httpd-2.2.19.tar.bz2
首先配置yum
上传源码
查看文件
[root@localhost ~]# ll
total 174788
-rw------- 1 root root
1140 Mar 5 05:47 anaconda-ks.cfg
drwxr-xr-x 2 root root
4096 Mar 5 21:53 Desktop
-rw-r--r-- 1 root root
5322082 May 22 2011 httpd-2.2.19.tar.bz2
-rw-r--r-- 1 root root
30104 Mar 5 05:47 install.log
-rw-r--r-- 1 root root
4261 Mar 5 05:45 install.log.syslog
-rw-r--r-- 1 root root 162247449 Jul 15 2011 mysql-5.5.15-linux2.6-i686.tar.gz
-rw-r--r-- 1 root root 11144328 Aug 18 2011 php-5.3.7.tar.bz2
-rw-r--r-- 1 root root
195 Mar 5 21:50 scsrun.log
[root@localhost ~]#
首先解压 mysql-5.5.15-linux2.6-i686.tar.gz
切换到/usr/local目录下 并做指向
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ll
total 76
drwxr-xr-x 2 root root 4096 Aug 8 2008 bin
drwxr-xr-x 2 root root 4096 Aug 8 2008 etc
drwxr-xr-x 2 root root 4096 Aug 8 2008 games
drwxr-xr-x 2 root root 4096 Aug 8 2008 include
drwxr-xr-x 2 root root 4096 Aug 8 2008 lib
drwxr-xr-x 2 root root 4096 Aug 8 2008 libexec
drwxr-xr-x 13 root root 4096 Mar 6 01:50 mysql-5.5.15-linux2.6-i686
drwxr-xr-x 2 root root 4096 Aug 8 2008 sbin
drwxr-xr-x 4 root root 4096 Mar 5 05:26 share
drwxr-xr-x 2 root root 4096 Aug 8 2008 src
[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686 mysql (mysql指向mysql-5.5.15-linux2.6-i686 头文件做链接)
[root@localhost local]# ll
total 76
drwxr-xr-x 2 root root 4096 Aug 8 2008 bin
drwxr-xr-x 2 root root 4096 Aug 8 2008 etc
drwxr-xr-x 2 root root 4096 Aug 8 2008 games
drwxr-xr-x 2 root root 4096 Aug 8 2008 include
drwxr-xr-x 2 root root 4096 Aug 8 2008 lib
drwxr-xr-x 2 root root 4096 Aug 8 2008 libexec
lrwxrwxrwx 1 root root
26 Mar 6 01:55 mysql -> mysql-5.5.15-linux2.6-i686
drwxr-xr-x 13 root root 4096 Mar 6 01:50 mysql-5.5.15-linux2.6-i686
drwxr-xr-x 2 root root 4096 Aug 8 2008 sbin
drwxr-xr-x 4 root root 4096 Mar 5 05:26 share
drwxr-xr-x 2 root root 4096 Aug 8 2008 src
进入mysql目录,查看其文件以及安装步骤
[root@localhost local]# cd mysql
[root@localhost mysql]# ll
total 76
drwxr-xr-x 2 root root
4096 Mar 6 01:50 bin
-rw-r--r-- 1 7161 wheel 17987 Jul 14 2011 COPYING
drwxr-xr-x 4 root root
4096 Mar 6 01:50 data
drwxr-xr-x 2 root root
4096 Mar 6 01:50 docs
drwxr-xr-x 3 root root
4096 Mar 6 01:50 include
-rw-r--r-- 1 7161 wheel 7604 Jul 14 2011 INSTALL-BINARY (安装步骤)
drwxr-xr-x 3 root root
4096 Mar 6 01:50 lib
drwxr-xr-x 4 root root
4096 Mar 6 01:49 man
drwxr-xr-x 10 root root
4096 Mar 6 01:50 mysql-test
-rw-r--r-- 1 7161 wheel 2552 Jul 14 2011 README
drwxr-xr-x 2 root root
4096 Mar 6 01:50 scripts
drwxr-xr-x 27 root root
4096 Mar 6 01:50 share
drwxr-xr-x 4 root root
4096 Mar 6 01:50 sql-bench
drwxr-xr-x 2 root root
4096 Mar 6 01:50 support-files
[root@localhost mysql]# less INSTALL-BINARY
To install and use a MySQL binary distribution, the basic command
sequence looks like this:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
开始执行install
[root@localhost mysql]# cd
[root@localhost ~]# groupadd mysql 创建组
[root@localhost ~]# useradd -r -g mysql mysql 创建用户
[root@localhost ~]# cd /usr/local/mysql 进入目录
[root@localhost mysql]# chown -R mysql 更改权限.
[root@localhost mysql]# chgrp -R mysql . 更改组
[root@localhost mysql]# 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!
[root@localhost mysql]# chown -R root .更改所属者
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf 拷贝mysql的配置文件
[root@localhost mysql]# bin/mysqld_safe --user=mysql & 执行
[1] 17190
[root@localhost mysql]# 120306 02:42:44 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120306 02:42:44 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
进入support-files目录下进行相应操作
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# ll
total 96
-rwxr-xr-x 1 root mysql 1153 Jul 14 2011 binary-configure
-rwxr-xr-x 1 root mysql 4528 Jul 14 2011 config.huge.ini
-rwxr-xr-x 1 root mysql 2382 Jul 14 2011 config.medium.ini
-rwxr-xr-x 1 root mysql 1626 Jul 14 2011 config.small.ini
-rw-r--r-- 1 root mysql
773 Jul 14 2011 magic
-rw-r--r-- 1 root mysql 4691 Jul 14 2011 my-huge.cnf
-rw-r--r-- 1 root mysql 19759 Jul 14 2011 my-innodb-heavy-4G.cnf
-rw-r--r-- 1 root mysql 4665 Jul 14 2011 my-large.cnf
-rw-r--r-- 1 root mysql 4676 Jul 14 2011 my-medium.cnf
-rw-r--r-- 1 root mysql 2840 Jul 14 2011 my-small.cnf
-rwxr-xr-x 1 root mysql 1061 Jul 14 2011 mysqld_multi.server
-rwxr-xr-x 1 root mysql
839 Jul 14 2011 mysql-log-rotate
-rwxr-xr-x 1 root mysql 10650 Jul 14 2011 mysql.server
-rwxr-xr-x 1 root mysql 1326 Jul 14 2011 ndb-config-2-node.ini
[root@localhost support-files]# cp my-large.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chkconfig --list |grep mysql 无服务
[root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig --list |grep mysql有服务
mysqld
0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost support-files]# service mysqld stop 关闭服务
Shutting down MySQL.120306 02:50:09 mysqld_safe mysqld from pid file /usr/local/mysql/data/localhost.localdomain.pid ended
[ OK ]
[1]+ Done
bin/mysqld_safe --user=mysql (wd: /usr/local/mysql)
(wd now: /usr/local/mysql/support-files)
[root@localhost support-files]# service mysqld start开启服务
Starting MySQL.
[ OK ]
[root@localhost support-files]# netstat -tpln |grep mysql
tcp
0 0 :::3306 :::* LISTEN 17781/mysqld (监听端口为3306)
[root@localhost support-files]#
修改环境变量
Vim /etc/profile
43 fi
44 PATH=$PATH:/usr/local/mysql/bin
45 export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
将头文件做成链接
[root@localhost mysql]# ln -s /usr/local/mysql/include mysql
库文件
[root@localhost ld.so.conf.d]# pwd
/etc/ld.so.conf.d
[root@localhost ld.so.conf.d]# vim mysqld.conf
/usr/local/mysql/lib
APACHE服务搭建
首先解压
httpd-2.2.19.tar.bz2
[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src/
如果需要 则安装下面两个工具包
[ root@server ~]# yum groupinstall "Development Libraries"
[root@server ~]# yum groupinstall "
Development Tools
"
检测编译环境
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/ht
tpd 脚本目录--enable-ssl(启用加密) --with-z(使用zlib) --enable-so(动态共享)脚本目录
编译开始 make
[root@localhost httpd-2.2.19]# make
安装开始
[root@localhost httpd-2.2.19]# make install (安装)
[root@localhost apache]# ./bin/apachectl start 启动服务
[root@localhost apache]# vim /etc/rc.d/rc.local编译设置为开机启动
7 touch /var/lock/subsys/local
8 /usr/local/apache/bin/apachectl start
[root@localhost apache]# vim /etc/profile编译环境变量
43 fi
44 PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin
修改头文件
[root@localhost ld.so.conf.d]# vim httpd.conf
/usr/local/apache/lib
读取库文件
[root@localhost ld.so.conf.d]# ldconfig -v |grep apache
/usr/local/apache/lib:
[root@localhost ld.so.conf.d]# ldconfig -v |grep mysql
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0
[root@localhost ld.so.conf.d]#
通过外部进行测试
PHP
安装
解压
[root@localhost ~]# tar jxvf php-5.3.7.tar.bz2 -C /usr/local/src (解压到目录)
[root@localhost ~]# cd /usr/local/src/php-5.3.7/
[root@localhost php-5.3.7]# less INSTALL
[root@localhost php-5.3.7]#./configure –prefix=usr/local/php --with-apx2=/usr/local/apache/bin/apax --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring=all执行检验编译安装
编译
[root@localhost php-5.3.7]# make
安装
[root@localhost php-5.3.7]# make install