mysql-5.5.15-linux2.6-i686.tar.gz //爲綠色軟件
php-5.3.7.tar.bz2
httpd-2.2.19.tar.bz2
2.編譯環境安裝gcc glib 包含着開發工具中
Development Tools --開發工具
Legacy Software Development -- 傳統軟件開發工具
Development Libraries –開發工具庫
Java development –源代碼基於java
如果是圖形的軟件包
Kde環境需要安裝:
Kde software developmen
t Gnome環境需要安裝:
Gnome software development
X software development
3.安裝過程刪除已經安裝過的包及安裝產生的文件
1擴展的查詢
rpm -qa |grep -E "http|php|mysql" –查看包是否已經安裝
--源碼安裝需要卸載,安裝全新的
# yum remove httpd
# yum remove mysql # yum remove php-common-5.1.6-23.el5
2刪除已安裝產生的配置文件
cd /etc/httpd
rm -fr *
額外被安裝的軟件一般都安裝到/usr/local目錄下
額外被安裝的源代碼一般都安裝在/usr/local/src and /usr/src mysql源碼安裝過程
[root@localhost ~]# tar zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/
[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql //做鏈接
[root@localhost local]# cd mysql
[root@localhost mysql]# less INSTALL-BINARY //查看安裝信息
安裝步驟
sequence looks like this:
shell> groupadd mysql //建立用戶組
shell> useradd -r -g mysql 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 . //改變所有文件屬有者爲mysql
shell> chgrp -R mysql . //改變所有文件的屬組爲mysql
shell> scripts/mysql_install_db --user=mysql //生成初始庫
shell> chown -R root . //改回來所有者所屬組
shell> chown -R mysql data // 改變data用戶
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf //生成配置腳本
shell> bin/mysqld_safe --user=mysql & //以mysql的身份啓動mysql
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server //生成服務的啓動腳本 [root@localhost mysql]# less INSTALL-BINARY
[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables... OK
Filling help tables... OK
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# bin/mysqld_safe --user=mysql &
[root@localhost mysql]# netstat -tupln |grep mysql
tcp 0 0 :::3306 :::* LISTEN 5103/mysqld
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld //生成服務的啓動腳本service mysqld start
--chkconfig管理mysqld服務
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# vim /etc/init.d/mysqld
# chkconfig: 2345 64 36
--啓動優先級序列號是 64 被殺死的號是36
[root@localhost mysql]# chkconfig mysqld on //設置開機啓動
[root@localhost mysql]# chkconfig --list mysqld mysqld
0:關閉 1:關閉 2:啓用 3:啓用 4:啓用 5:啓用 6:關閉
更改庫文件
標準庫文件存放目錄
/lib
/usr/lib
/usr/local/lib
庫文件存放三個文件裏系統會自動找到
[root@localhost mysql]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
--定義不標準軟件包安裝的庫文件存放位置
[root@localhost mysql]# cd /etc/ld.so.conf.d/
[root@localhost ld.so.conf.d]# vim mysql.conf //創建新的庫文件路徑指向文件
/usr/local/mysql/lib
[root@localhost ld.so.conf.d]# ldconfig -v |grep mysql //重新加載庫文件--查看能否加載上
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0 //已經加載
更改頭文件
-頭文件存放位置
/usr/include
/usr/local/include
[root@localhost ld.so.conf.d]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/mysql/include/ mysql //連接到mysql的頭文件命名爲mysql
apache源碼安裝過程[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/src/
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ll
總計 20
drwxr-xr-x 11 500 mysql 4096 2011-05-21 httpd-2.2.19
drwxr-xr-x 3 root root 4096 2012-08-11 kernels
drwxr-xr-x 7 root root 4096 2012-08-11 redhat
[root@localhost src]# cd httpd-2.2.19/
[root@localhost httpd-2.2.19]# less INSTALL //安裝說明文檔
http://httpd.apache.org/docs/2.2/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start //配置步驟
[root@localhost httpd-2.2.19]# ./configure –help //查看幫助文檔
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/apache2] //安裝的路徑
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] //配置腳本存放位置
--enable-so DSO capability //開啓DSO (動態共享對象)
--with-z=DIR zlib use a specific zlib library //使用zlib庫需要安裝 (確保安裝了zlib 以及 zlib-devel)
--enable-ssl SSL/TLS support (mod_ssl) //啓用加密
[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --with-z --enable-ssl
會檢測預編譯環境
[root@localhost httpd-2.2.19]# make //編譯
[root@localhost httpd-2.2.19]# make install //安裝
[root@localhost httpd-2.2.19]# cd /usr/local/apache/ //產生的apache目錄
[root@localhost apache]# ./bin/apachectl start //啓動apache
[root@localhost apache]# vim /etc/rc.d/rc.local //編寫開機腳本
touch /var/lock/subsys/local
/usr/local/apache/bin/apachectl start
[root@localhost ~]# vim /etc/profile //爲了啓動方便修改環境變量
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
PATH=$PATH:/usr/local/apache/bin //添加的環境變量
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC //在這裏邊添加環境變量
//要想使生效註銷一次在登錄就生效了 不用註銷的就可以生效的方法是執行下命令
[root@localhost ~]# . /etc/profile
[root@localhost ~]# echo $PATH //查看添加的結果
/usr/local/apache/bin
[root@localhost ~]# apachectl stop //這是在任何位置都可以啓動和停止
[root@localhost apache]# cd /usr/include/ //進到標準頭文件
[root@localhost include]# ln -s /usr/local/apache/include apache //做一個鏈接到apache的頭文件
[root@localhost include]# cd /etc/ld.so.conf.d/ //鏈接庫文件
[root@localhost ld.so.conf.d]# vim apache.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 -pv |grep apache //查看是否加載成功
libaprutil-1.so.0 (libc6) => /usr/local/apache/lib/libaprutil-1.so.0
libaprutil-1.so (libc6) => /usr/local/apache/lib/libaprutil-1.so
libapr-1.so.0 (libc6) => /usr/local/apache/lib/libapr-1.so.0
libapr-1.so (libc6) => /usr/local/apache/lib/libapr-1.so
Php的源碼安裝
php作爲apache的模塊被調用
[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/src/
[root@localhost ~]# cd /usr/src/php-5.3.7/
[root@localhost php-5.3.7]# less INSTALL
Example #1 Installation Instructions (Apache Shared Module Version) for
PHP
1. gunzip apache_xxx.tar.gz
2. tar -xvf apache_xxx.tar
3. gunzip php-xxx.tar.gz
4. tar -xvf php-xxx.tar
5. cd apache_xxx
6. ./configure --prefix=/www --enable-module=so
7. make
8. make install
9. cd ../php-xxx
[root@localhost php-5.3.7]# ./configure -help
--prefix //安裝路徑
--with-apxs2 //指明apache調用php模塊的工具的路徑和名稱
--enable-mbstring //字符串支持
--with-mysql //指明mysql的路徑
--with-mysqli //指明mysql_config的路徑名稱
[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
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make install
[root@localhost php-5.3.7]# vim /etc/httpd/httpd.conf
105 DocumentRoot "/usr/local/apache/htdocs" //網頁主頁位置
[root@localhost php-5.3.7]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# ll
total 4
-rw-r--r-- 1 root root 44 Nov 21 2004 index.html
[root@localhost htdocs]# vim index.html
<html><body><h1>It works!</h1></body></html>
<?php
phpinfo();
?>
[root@localhost htdocs]# mv index.html index.php
[root@localhost htdocs]# vim /etc/httpd/httpd.conf //配置
167 DirectoryIndex index.php index.html //添加index.php
310 AddType application/x-httpd-php .php //添加 (調用php模塊)
[root@localhost htdocs]# apachectl stop
[root@localhost htdocs]# apachectl start
在客戶端測試輸入http://192.168.145.100
[root@localhost htdocs]# vim index.php //測試mysql能否鏈接
<?php
$link=mysql_connect('127.0.0.1','root','');
if($link)
echo "ok";
else
echo "failer";
?>