最新全面源码包安装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的安装
依赖性包:
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/
#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
tar zxvf cmake-2.8.6.tar.gz -C /usr/src/
tar zxvf bison-2.5.1.tar.gz -C /usr/src/
tar zxvf mysql-5.5.30.tar.gz -C /usr/src/
#bin/bash
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 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 php-5.4.14.tar.gz -C /usr/src/
#bin/bash
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
ldconfig
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
<?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,如需转载请自行联系原作者