首先在網上下載源代碼包
mysql-5.5.15-linux2.6-i686.tar.gz
httpd-2.2.19.tar.bz2
php-5.3.7.tar.bz2
mysql源碼安裝過程--------------------------
[root@localhost Server]# yum clean all
[root@localhost Server]# yum groupinstall "Development Tools"
[root@localhost Server]# rpm -qa |grep -E "http|php|mysql"////查詢是否安裝
[root@localhost Server]# yum remove httpd//////卸載軟件
[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
-rw-r--r-- 1 7161 wheel 7604 Jul 14 03:09 INSTALL-BINARY
[root@localhost mysql]# less INSTALL-BINARY /////查看內容
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//////以上爲安裝步驟
[root@localhost mysql]# groupadd -r mysql /////創建系統組
[root@localhost mysql]# useradd -r -g mysql -s /sbin/nologin -M mysql
[root@localhost mysql]# chown -R mysql:mysql . //////修改所有者和所屬組
[root@localhost mysql]# scripts/mysql_install_db --user=mysql------"1980s:lamp-1"-----
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# ll /etc/init.d/ ///////存放的全都是各種啓動腳本
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf//////mysql的配置腳本
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld //////mysql的啓動腳本
[root@localhost mysql]# service mysqld start//////可以對mysql進行啓動、關閉、
[root@localhost mysql]# netstat -tupln |grep mysql/////啓動後可以查看mysql的端口號
[root@localhost mysql]# cd /etc/ld.so.conf.d/ /////配置非標準的庫文件
[root@localhost ld.so.conf.d]# vi 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//////說明已經加載上
[root@localhost ld.so.conf.d]# cd /usr/include/ /////頭文件存放目錄
[root@localhost include]# ln -s /usr/local/mysql/include mysql///////連接到mysql的頭文件命名爲mysql
[root@localhost include]# cd mysql //////就可進入到mysql的頭文件裏
[root@localhost mysql]# chkconfig --add mysql //////添加到開機自啓動裏
[root@localhost mysql]# chkconfig --list |grep mysql
[root@localhost mysql]# cd /etc/rc3.d/ ////可以進入到3級別查看在3級別裏的內容
apache源碼安裝過程------------------------------
額外被安裝的軟件一般都安裝到/usr/local目錄下
額外被安裝的源代碼一般都安裝在/usr/local/src and /usr/src
[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/src/ ////拆解安裝源代碼包到/usr/src/
[root@localhost ~]# cd /usr/src/ ////在這個目錄下會有這個目錄
drwxr-xr-x 11 yl yl 4096 May 21 01:01 httpd-2.2.19
[root@localhost src]# cd httpd-2.2.19/ /////繼續切換到這個目錄下
[root@localhost httpd-2.2.19]# ls //////查看文件
[root@localhost httpd-2.2.19]# less INSTALL /////查看配置文件說明
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start /////配置步驟
[root@localhost httpd-2.2.19]# ./configure --help //////查看幫助文檔
Installation directories:
--prefix=PREFIX //安裝成功後的路徑 install architecture-independent files in PREFIX
[/usr/local/apache2]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
--sysconfdir=DIR ///配置腳本存放位置 read-only single-machine data [PREFIX/etc]
--enable-so DSO capability ///開啓DSO (動態共享對象)
--with-z=DIR ///使用zlib庫需要安裝zlib use a specific zlib library
[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 /etc/httpd/
-rw-r--r-- 1 root root 13422 Sep 7 08:04 httpd.conf
[root@localhost httpd]# vi httpd.conf
[root@localhost httpd]# cd extra/
-rw-r--r-- 1 root root 1491 Sep 7 08:04 httpd-vhosts.conf
[root@localhost extra]# vi httpd-vhosts.conf///////在這裏可以編寫虛擬主機目錄
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
[root@localhost extra]# cd /usr/local/apache/ /////產生的apache目錄
[root@localhost apache]# ./bin/apachectl start ////啓動apache
[root@localhost apache]# vi /etc/rc.d/rc.local /////編寫開機腳本
/usr/local/apache/bin/apachectl start
[root@localhost ~]# vi /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]# vi mysql.conf
/usr/local/apache/lib
[root@localhost ld.so.conf.d]# ldconfig -v |grep apache /////重新加載
/usr/local/apache/lib:
php源碼安裝過程--------------------------------
同樣是源代碼需要解壓到/usr/src
[root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/src/
[root@localhost ~]# cd /usr/src/
drwxr-xr-x 13 1000 1000 4096 Aug 17 21:32 php-5.3.7
[root@localhost src]# cd php-5.3.7/
[root@localhost php-5.3.7]# ls
INSTALL //////同樣有一個INSTALL文件有配置--安裝---注意的選項
[root@localhost php-5.3.7]# vi INSTALL
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=PREFIX /////安裝路徑
--with-apxs2[=FILE]=指明apache調用php模塊的工具的路徑和名稱
--enable-mbstring ///////字符串支持
--with-mysql 指明mysql路徑
--with-mysqli 指明mysql_confi 的路徑名稱
1.[root@localhost php-5.3.7]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
2.[root@localhost php-5.3.7]# make
3.[root@localhost php-5.3.7]# make install
[root@localhost php-5.3.7]# vi /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]# vi index.html
<?php
phpinfo();
?>
[root@localhost htdocs]# mv index.html index.php
[root@localhost htdocs]# vi /etc/httpd/httpd.conf /////配置
167 DirectoryIndex index.php index.html //////添加index.php
310 AddType application/x-httpd-php .php /////添加
[root@localhost htdocs]# apachectl stop
[root@localhost htdocs]# apachectl start
[root@localhost htdocs]# vi index.php /////測試mysql能否鏈接
<?php
$link=mysql_connect('127.0.0.1','root','');
if($link)
echo "ok";
else
echo "failer"
?>
測試在網頁上做測試如http://192.168.101.27 ok說明可以連接上