Linux下源代碼安裝apache+mysql+php

 Linux下源代碼安裝apache+mysql+phpphp

 
/*******************************
* I am pefocus,pefocus is me !*
*******************************/
 
編譯環境:RedHat Enterprise AS 5,開啓SELlinux
 
所須要的軟件:apache,php,phpmyadmin,mysql,GD及庫相關 
libpng-1.2.24.tar.bz2 
zlib-1.2.3.tar.gz
freetype-2.3.5.tar.gz 
libxslt-1.1.22.tar.gz 
jpegsrc.v6b.tar.gz
gd-2.0.36RC1.tar.bz2 
libxml2-2.6.30.tar.gz 
 
下載地址:
http://www.apache.org
http://www.php.net
http://www.mysql.com
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz
http://prdownloads.sourceforge.net/l...ar.gz?download
http://easynews.dl.sourceforge.net/s...-2.1.3.tar.bz2
http://telia.dl.sourceforge.net/sour...-2.1.3.tar.bz2
 
1.安裝apache
tar -xvf httpd-2.2.0.tar.gz
cd httpd-2.2.0
./configure --prefix=/usr/local/apache2 --enable-module=so
make
make install
 
設置apache自啓動:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
而後vi /etc/init.d/httpd
在第3行加入
# chkconfig: 2345 70 30
# processname: httpd
注意:#號不能去掉!
最後chkconfig --add httpd
 
2.freetype
tar vjf freetype-2.1.3.tar.bz2
cd freetype-2.1.3
./configure
make
make install
 
3.jpeg
tar xvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-shared --enable-static
make
mkdir -v /usr/local/man
mkdir -v /usr/local/man/man1
make install
 
4.zlib
tar xvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
 
5.libpng
./configure
make
make test
make install
 
6.gd2
tar xvf gd-2.0.27.tar.gz
cd gd-2.0.27/
./configure --prefix=/usr/local/gd2
make
make install
 
7.mysql
 
groupadd mysql 
useradd -g mysql mysql
cd /data/ ----這是我安裝mysql的目錄,可根據實際狀況更改,如cd /usr/local/
tar xvf mysql-5.0.41-linux-i686-glibc23.tar.gz
cd mysql-5.0.41-linux-i686-glibc23/
chown -R mysql .
chgrp -R mysql .
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
./bin/mysqld_safe --user=mysql &
 
注意:安裝完成後,爲root用戶設置密碼 !
運行如下命令:
./bin/mysqladmin -u root password 'new-password'或者
./bin/mysqladmin -u root -h hostname password 'new-password'
 
設置mysql自啓動:
cp support-files/mysql.server /etc/init.d/mysql
chmod +x mysql
chkconfig --add mysql
運行mysql:
/etc/init.d/mysql star|stop|restart或者
service mysql star|stop|restart
 
8.php
安裝php的時候,系統默認缺乏兩個組件 FLEX,libxml2
 
tar xvf php-5.2.5.tar.gz
cd php-5.2.5/
./configure --with-gd=/usr/local/gd2 --with-apxs2=/usr/local/apache2/bin/apxs --with-xml --with-mysql=/data/mysql5
make
make install
...
Installing PEAR environment: /usr/local/lib/php/
/usr/local/php-5.2.5/sapi/cli/php: error while loading shared libraries: /usr/local/gd2/lib/libgd.so.2: cannot restore segment prot after reloc: Permission denied
make[1]: *** [install-pear-installer] Error 127
make: *** [install-pear] Error 2
安裝出錯,輸入tail /var/log/messages
...
Mar 3 06:40:46 localhost setroubleshoot: SELinux is preventing /usr/local/php-5.2.5/sapi/cli/php from loading /usr/local/gd2/lib/libgd.so.2.0.0 which requires text relocation. For complete SELinux messages. run sealert -l 6e29749f-3908-480d-bcc1-9042f8a9e846
 
運行 sealert -l 6e29749f-3908-480d-bcc1-9042f8a9e846
...
The following command will allow this access:
chcon -t textrel_shlib_t /usr/local/gd2/lib/libgd.so.2.0.0
運行 chcon -t textrel_shlib_t /usr/local/gd2/lib/libgd.so.2.0.0
再次運行make install ,安裝成功。
cp php.ini-dist /usr/local/lib/php.ini
 
9.配置apche
記得備份httpd.conf
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak
vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
 
DocumentRoot 改爲你但願指定的主目錄,如/data/www
IfModule dir_module 在這裏加上你但願做爲默認首頁的文件,我加了index.htm index.php,中間打個空格就能夠了
 
若是你想啓動apache支持shtml格式,能夠這樣操做
找到下面這樣一段文字
This should be changed to whatever you set DocumentRoot to.
把<Directory "/usr/local/apache/htdocs">改爲你的主目錄
若是不但願有人能看到網站目錄結構,在下面加入Options FollowSymLinks Includes,注意區分大小寫
 
完成這部之後,查找這兩行,把前面的#去掉
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
 
從新啓動apache,在www目錄下創建文件phpinfo.php
<?php
phpinfo();
?>
 
運行http://localhost/phpinfo.php,測試。
若是apache不能正常解析php,在http.conf中查找LoadModule php5_module modules/libphp5.so
若是沒有則添加。
相關文章
相關標籤/搜索