1.准备 php函数的 rpm包
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel
libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib
zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses
ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn
libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap
openldap-clients openldap-servers
2.准备lnmp源代码安装的所需要的源码包
1).nginx http://nginx.org 下载
wget
http://nginx.org/download/nginx-1.5.13.tar.gz
2).php http://php.net 下载
3).mysql http://www.mysql.com 下载
wget
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
4).libiconv http://www.gnu.org/software/libiconv/
下载[http://ftp.gnu.org/gnu/libiconv/]
wget
http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
5).libmcrypt
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/ 下载
[这个地址要翻墙]
6).mcrypt [google mcrypt download]
http://sourceforge.net/projects/mcrypt/
下载 [这个地址要翻墙]
/*
configure不通过,提示:
checking for mhash_keygen in
-lmhash... no
configure: error: "You need at least libmhash 0.8.15 to compile
this program. http://mhash.sf.net/"
解决:
export
LD_LIBRARY_PATH=/home/felix021/lamp/libmcrypt/lib:/home/felix021/lamp/mhash/lib
export
LDFLAGS="-L/home/felix021/lamp/mhash/lib/
-I/home/felix021/lamp/mhash/include/"
export
CFLAGS="-I/home/felix021/lamp/mhash/include/"
./configure
--prefix=/home/felix021/lamp/mcrypt/
\
--with-libmcrypt-prefix=/home/felix021/lamp/libmcrypt
*/
7).mhash
http://sourceforge.net/projects/mhash/files/mhash/0.9.9/ 下载
[这个地址要翻墙]
8).pcre
http://sourceforge.net/projects/pcre/files/pcre/ 下载 [这个地址要翻墙]
9).pdo_mysql
http://pecl.php.net/package/PDO_MYSQL下载
10).imagemagick
http://www.imagemagick.org/script/download.php
下载[找亚洲的源,这样快点]
11).imagick
http://pecl.php.net/package/imagick
12).memcache
http://memcached.org/
13).eaccelerator
http://eaccelerator.net/
3.安装 php-5.2.14 源代码包所需要的函数支持包
tar zxvf libiconv-1.13.1.tar.gz
cd
libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
cd libltdl/
./configure --enable-ltdl-install
make
make install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
## 让支持包加入到内存中,使其别的软件能够找到
vi /etc/ld.so.conf
添加:
/usr/local/lib
这行
ldconfig 命令一下
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
4.编译安装 MySQL
mysql-5.5.3以前可以用
./configure --prefix=/usr/local/mysql
--without-debug --enable-thread-safe-client --with-pthread --enable-assembler
--enable-profiling --with-mysqld-ldflags=-all-static
--with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all
--with-mysqld-user=mysql --without-embedded-server
--with-server-suffix=-community --with-unix-socket-path=/tmp/mysql.sock
mysql5.5.3之后用cmake来安装
1).安装cmake
yum -y install
cmake.i686
2).安装mysql
#建立mysql用户
useradd -s /sbin/nologin mysql
#
cmake测试
cmake -DMYSQL_USER=mysql -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.6
-DINSTALL_DATADIR=/data/mysql/data -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
-DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
#这之后步骤一样
make
make install
#设置权限
setfacl -m u:mysql:rxw -R /usr/local/mysql5.6
setfacl -m
d:u:mysql:rxw -R /usr/local/mysql5.6
# 安装mysql和test数据库
/usr/local/mysql5.6/scripts/mysql_install_db
--user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql5.6/
--datadir=/usr/local/mysql5.6/data
# 启动mysql服务
/usr/local/mysql5.6/bin/mysqld_safe --user=mysql & 或
cp
源码包/support-files/mysql.server /etc/init.d/mysqld
chkconfig --level 345
mysqld on
service mysqld start
# 修改msyql登陆root的密码
/usr/local/mysql5.6/bin/mysqladmin -uroot -password
"123456"
# 用mysql登录
/usr/local/mysql5.6/bin/mysql -uroot -p123
#准备 mysql 配置文件
cp /usr/local/mysql5.6/share/mysql/my-medium.cnf
/etc/my.cnf 或
cp 源码包/support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf
#修改客户端和连接字符集 [client]
default-character-set=utf8
[mysqld]
#修改服务器和数据库字符集
character-set-server=utf8
#修改服务器校验字符集
collation-server=utf8
#重启 mysql 服务让字符集生效
pkill mysqld
/usr/local/mysql5.6/bin/mysqld_safe
--user=mysql &
5. 编译安装 PHP(FastCGI 模式)
cd php-5.2.14/
./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path
--enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem
--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex
--enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring
--with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash
--enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc
--enable-zip --enable-soap
make ZEND_EXTRA_LIBS=‘-liconv‘
make install
cp 源码包/php.ini-production /usr/local/php/etc/php.ini
##############################################################################
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
#nginx所需要的库文件件
yum -y install pcre-devel zlib-devel
#PHP依赖的库文件
yum -y install gd-devel libjpeg-devel libpng-devel
freetype-devel libxml2-devel curl-devel
安装库文件
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
/sbin/ldconfig
cd libltdl
./configure --enable-ltdl-install
make && make
install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
##
让支持包加入到内存中,使其别的软件能够找到
vi /etc/ld.so.conf
添加: /usr/local/lib
这行
/sbin/ldconfig
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install
# 安装php
tar zxvf php-5.4.0.tar.gz
cd php-5.4.0.tar.gz
./configure --prefix=/usr/local/php5.4 \
--with-config-file-path=/etc
\
--with-iconv-dir=/usr/local/ --with-freetype-dir \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-jpeg-dir
--with-png-dir --with-zlib \
--with-mhash --enable-sockets --enable-ftp \
--with-libxml-dir --enable-xml --disable-rpath \
--enable-bcmath \
--enable-shmop --enable-sysvsem \
--enable-inline-optimization
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd \
--enable-gd-native-ttf
--with-openssl --with-mhash \
--enable-pcntl --enable-sockets --with-ldap
--with-ldap-sasl \
--enable-fpm \
--with-xmlrpc --enable-zip
--enable-soap \
--without-pear
make ZEND_EXTRA_LIBS=‘-liconv‘
make install
cp
php.ini-production /etc/php.ini
将php-fpm 作为服务运行
cp /soft/php-5.4/sapi/fpm/init.d.php-fpm
/etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
chkconfig --add
php-fpm
chkconfig --level 345 php-fpm on
服务方式启动php-fpm
service
php-fpm start
【2】编译Nginx
安装pcre
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32/
./configure --prefix=/usr/local/pcre
make && make install
安装nginx
tar zxvf nginx-1.0.15.tar.gz
cd nginx-1.0.15/
./configure --user=www --group=www --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_ssl_module
--with-http_gzip_static_module --with-ipv6
make && make install
原文:http://www.cnblogs.com/ahwu/p/3656553.html