最新全面源碼包安裝lamp
LAMP架構需要的源碼包位址
apache的依賴性包:
wget http://mirror.bjtu.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
wget http://mirror.bjtu.edu.cn/apache/apr/apr-1.4.6.tar.gz
wget http://ncu.dl.sourceforge.net/project/pcre/pcre/8.11/pcre-8.11.tar.gz
wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.2.tar.gz
mysql的依賴性包:
wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz
wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.30.tar.gz
php的依賴性包:(http://www.gnu.org/software/libiconv/)
wget http://ncu.dl.sourceforge.net/project/qdbm/qdbm/1.8.77/qdbm-1.8.77.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget http://fossies.org/linux/www/gd-2.0.35.tar.gz
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
wget http://cn2.php.net/distributions/php-5.4.14.tar.gz
yum -y install gcc gcc-c++ openssl-devel
tar zxvf apr-1.4.2.tar.gz -C /usr/src/
tar zxvf apr-util-1.3.10.tar.gz -C /usr/src/
tar zxvf pcre-8.11.tar.gz -C /usr/src/
tar zxvf cmake-2.8.6.tar.gz -C /usr/src/
tar zxvf bison-2.5.1.tar.gz -C /usr/src/
tar zxvf libiconv-1.14.tar.gz -C /usr/src/
tar zxvf qdbm-1.8.77.tar.gz -C /usr/src/
tar zxvf gd-2.0.35.tar.gz -C /usr/src/
tar jxvf libmcrypt-2.5.8.tar.bz2 -C /usr/src/
tar jxvf mhash-0.9.9.9.tar.bz2 -C /usr/src/
tar zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
tar zxvf cronolog-1.6.2.tar.gz -C /usr/src/
tar zxvf httpd-2.4.3.tar.gz -C /usr/src/
tar zxvf mysql-5.5.30.tar.gz -C /usr/src/
tar zxvf php-5.4.14.tar.gz -C /usr/src/
apache的安裝
依賴性包:
#bin/bash
yum -y remove httpd
echo "##### apr install#####"
cd /usr/src/apr-1.4.2
./configure --prefix=/usr/local/apr && make && make install && echo "ok!!!"
echo "##### apr-util install#####"
cd /usr/src/apr-util-1.3.10
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config && make && make install
echo "##### pcre install#####"
cd /usr/src/pcre-8.11
./configure --prefix=/usr/local/pcre && make && make install
echo "##### httpd install######"
cd /usr/src/httpd-2.4.3
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite --enable-ssl --with-ssl=/usr/lib--enable-auth-digest --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache2/htdocs && make && make install
echo "####httpd is installed######"
httpd編譯完成後:
源碼包安裝httpd啟動為/usr/local/apache/bin/httpd -k start //啟動
修改啟動指令方式
cp /usr/src/httpd-2.4.3/build/rpm/httpd.init /etc/init.d/httpd
vim /etc/init.d/httpd
########修改一些内容
prog=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
if [ -f /etc/sysconfig/${prog} ]; then
. /etc/sysconfig/${prog}
fi
d
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
########儲存退出
然後在修改apache的配置檔案
vim /usr/local/apache2/conf/httpd.conf
###添加這句
pidfile "/usr/local/apache2/httpd.pid"
###然後儲存退出配置檔案
設定開機自啟
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 35 httpd on
mysql的安裝
yum -y install ncurses ncurses-devel
useradd -M -s /sbin/nologin mysql
echo "##### cmake install#####"
cd /usr/src/cmake-2.8.6
./bootstrap && gmake && gmake install
echo "##### bison install#####"
cd /usr/src/bison-2.5.1/
./configure && make && make install
echo "##### mysql install#####"
cd /usr/src/mysql-5.5.30/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data && make && make install
echo "######mysql is install#####"
mysql編譯完成後:
第1步:複制配置檔案與開機啟動服務
cp usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf (記憶體大就選這個)
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
第2步:初始化資料庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/var/mysql/data
/usr/local/mysql/bin/mysqld_safe --user=mysql
第3步:給檔案夾設定權限
chmod -R 755 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /var/mysql/data
第4步:開啟服務
service mysqld start| stop | restart
/usr/local/mysql/bin/mysqladmin -u root password 給root使用者設定密碼
/usr/local/mysql/bin/mysql -u root -p 登入資料庫
這樣每次這樣敲這麼多很麻煩,把mysql指令的腳本工具添加到系統檔案/etc/profile中
export PATH=$PATH:/usr/local/mysql/bin/
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
以後進去直接就可以mys
mysql -u root -p
第5步:設定開機自啟
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
php的安裝
tar jxvf libmcrypt-2.5.8.tar.bz2-C /usr/src/
echo "####libiconv install####"
cd /usr/src/libiconv-1.14/
./configure --prefix=/usr/local/libiconv && make && make install
echo "####qdbm install#####"
cd /usr/src/qdbm-1.8.77/
./configure --prefix=/usr/local/qdbm --enable-devel --enable-zlib --enable-iconv && make && make install
echo "####gd install####"
cd /usr/src/gd/2.0.35
./configure --prefix=/usr/local/gd2 --with-jpeg --with-png --with-zlib --with-freetype && make && make install
vim /usr/local/gd2/include/gd_io.h
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}
gdIOCtx;
echo "/usr/local/gd2/lib" >> /etc/ld.so.conf
ldconfig
echo "####libmcrypt and libltdl install####"
cd /usr/src/libmcrypt-2.5.8/
./configure --prefix=/usr/local/libmcrypt && make && make install
cd usr/src/libmcrypt-2.5.8/libltdl
./configure --prefix=/usr/local/libltdl --enable-ltdl-install && make && make install
ln -sf /usr/local/lib/libmcrypt.* /usr/lib
ln -sf /usr/local/bin/libmcrypt-config /usr/bin
echo "####mhash install####"
cd /usr/src/mhash-0.9.9.9/
./configure --prefix=/usr/local/mhash && make && make install
ln -sf /usr/local/lib/libmhash.* /usr/lib/
echo "####mcrypt install####"
cd /usr/src/mcrypt-2.6.8/
/sbin/ldconfig
./configure --prefix=/usr/local/mcrypt && make && make install
echo "####cronolog install####"
cd /usr/src/cronolog-1.6.2
./configure --prefix=/usr/local/cronolog && make && make install
echo "####php install#####"
ln -sf /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib
ln -sf /usr/local/qdbm/lib/libqdbm.so* /usr/lib
yum -y install bzip2 bzip2-devel curl-devel libjpeg-devel libxml2* libpng* freetype* libxslt*
cd /usr/src/php-5.4.14
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-iconv=/usr/local/libiconv \
--with-gd=/usr/local/gd2 \
--with-iconv-dir=/usr/local \
--with-pdo-mysql=/usr/local/mysql \
--with-libxml-dir=/usr \
--with-qdbm=/usr/local/qdbm \
--with-mime-magic=/usr/share/file/magic \
--with-jpeg-dir --with-png-dir --with-freetype-dir \
--with-bz2 --with-zlib --without-pear --with-mcrypt=/usr/local/libmcrypt --with-mhash \
--with-xmlrpc --with-zlib-dir --with-curl --with-curlwrappers \
--with-ttf --with-xsl --with-gettext --with-pear --with-openssl \
--enable-discard-path --enable-gd-native-ttf \
--enable-bcmath --enable-shmop --enable-sysvsem \
--enable-inline-optimization --enable-mbregex --enable-xml \
--enable-soap --enable-calendar --enable-wddx --enable-dba \
--enable-gd-native-ttf--enable-calendar --enable-safe-mode \
--enable-ftp --enable-zip --enable-mbstring --enable-bcmath \
--enable-sockets --enable-exif --enable-magic-quotes \
--disable-rpath --disable-debug
make && make install
echo "####php is install#####"
編譯安裝完成後,先複制php.ini配置檔案
cp /usr/src/php-5.4.11/php.ini-production /usr/local/php5/php.ini
這步如果沒錯,那就證明你的php已經搭建好了。
¥¥¥¥¥¥
給大家一些參考./configure
–-prefix=/usr/local/php5 php 安裝目錄
--with-apxs2=/usr/local/apache2/bin/apxs
–-with-config-file-path=/usr/local/php5/etc 指定php.ini位置
–-with-mysql=/usr/local/mysql mysql安裝目錄,對mysql的支援
–-with-mysqli=/usr/local/mysql/bin/mysql_config mysqli檔案目錄,優化支援
–-enable-safe-mode 打開安全模式
–-enable-ftp 打開ftp的支援
–-enable-zip 打開對zip的支援
–-with-bz2 打開對bz2檔案的支援
–-with-jpeg-dir 打開對jpeg圖檔的支援
–-with-png-dir 打開對png圖檔的支援
–-with-freetype-dir 打開對freetype字型庫的支援
–-without-iconv 關閉iconv函數,種字元集間的轉換
–-with-libXML-dir 打開libxml2庫的支援
–-with-XMLrpc 打開xml-rpc的c語言
–-with-zlib-dir 打開zlib庫的支援
–-with-gd 打開gd庫的支援
–-enable-gd-native-ttf 支援TrueType字元串函數庫
–-with-curl 打開curl浏覽工具的支援
–-with-curlwrappers 運用curl工具打開url流
–-with-ttf 打開freetype1.*的支援,可以不加了
–-with-xsl 打開XSLT 檔案支援,擴充了libXML2庫 ,需要libxslt軟體
–-with-gettext 打開gnu 的gettext 支援,編碼庫用到
–-with-pear 打開pear指令的支援,PHP擴充用的
–-enable-calendar 打開月曆擴充功能
–-enable-mbstring 多位元組,字元串的支援
–-enable-bcmath 打開圖檔大小調整,用到zabbix監控的時候用到了這個子產品
–-enable-sockets 打開 sockets 支援
–-enable-exif 圖檔的中繼資料支援
–-enable-magic-quotes 魔術引用的支援
–-disable-rpath 關閉額外的運作庫檔案
–-disable-debug 關閉調試模式
–-with-mime-magic=/usr/share/file/magic.mime 魔術頭檔案位置
以編輯完的php添加子產品
#install wso2-wsf
cd /usr/src
unzip wso2-wsf-php-src-2.1.0.zip
cd wso2-wsf-php-src-2.1.0
/usr/local/php5/bin/phpize
./configure --with-php-config=/usr/local/php5/bin/php-config --prefix=/usr/local/wso2
make
make install
sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/php5/etc/php.ini
echo 'extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/"' >> /usr/local/php5/etc/php.ini
這個LAMP架構就搭建完了,現在我們來測試一下
第1;us 先測試apache與php的協同工作
vim /usr/local/apache2/conf/httpd.conf在apache的配置檔案裡面添加下面幾句
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
然後在網頁根目錄檔案裡面寫一個測試test.php
vim /usr/local/apache2/htdocs/test.php
<?php
phpinfo();
?>
然後自己打開IE測試一下http://ip(本機的ip或者域名)/test.php
第2;測試php與mysql的協同工作
vim /usr/local/apache2/htdocs/testdb.php
$link=mysql_connect('localhost','test','');
if(!$link) echo "mysql test fail!!";
else echo "mysql test success!!!";
mysql_close();
然後自己打開IE測試一下http://ip(本機的ip或者域名)/testdb.php
看見 mysql test success!!! 那ok了,lamp架構搭建成功了。
本文轉自 jie783213507 51CTO部落格,原文連結:http://blog.51cto.com/litaotao/1186920,如需轉載請自行聯系原作者