一、 首先交代一个环境问题,编译安装pcre的时候经常会因为没有安装gcc而报c compiler cc is not found
搭建yum源,yum install -y gcc*
建议将lnmp架构所需环境一起搭建,防止编译过程中报错,然后再装各种包
所以,我们直接采用yum安装 .配置编译需要的环境
yum -y install autoconf bzip2 bzip2-devel curl curl-devel e2fsprogs e2fsprogs-devel freetype freetype-devel gcc gcc-c++ gcc-g77 gd gd-devel glib2 glib2-devel glibc glibc-devel krb5 krb5-devel libevent libevent-devel libidn libidn-devel libjpeg libjpeg-devel libpng libpng10 libpng10-devel libpng-devel libtool libtool-libs libxml2 libxml2-devel make ncurses ncurses-devel nss_ldap openldap openldap-clients openldap-devel openldap-servers openssl openssl-devel patch pspell-devel zlib zlib-devel 2
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
二 、nignx的编译安装
在安装nginx之前,为了防止报错,建议
yum -y groupinstall "Development Tools" "Development Libraries"
[root@kissing nginx-1.0.13]# ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/usr
/local/nginx/etc/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nignx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
make && make install
[root@kissing nginx]# mv nginx /etc/init.d/
[root@kissing nginx]# chmod +x /etc/init.d/nginx
[root@kissing nginx]# /etc/init.d/nginx start
sed: -e expression #1, char 14: unterminated `s' command
Starting nginx: /usr/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory [FAILED]
[root@kissing nginx]# updatedb
[root@kissing nginx]# locate libpcre.so.1
/usr/local/lib/libpcre.so.1
/usr/local/lib/libpcre.so.1.2.0
[root@kissing nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib
[root@kissing nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[root@kissing nginx]# /etc/init.d/nginx start
sed: -e expression #1, char 14: unterminated `s' command
chown: missing operand after `/var/tmp/nginx/fcgi'
Try `chown --help' for more information.
chown: missing operand after `/var/tmp/nginx/uwsgi'
Try `chown --help' for more information.
chown: missing operand after `/var/tmp/nginx/scgi'
Try `chown --help' for more information.
Starting nginx: [ OK ]
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
三 、mysql的编译安装
可以参考http://blog.csdn.net/quanliyadan/article/details/11553719
新建用户及相关目录,并修改相关的属主和属组。
useradd mysql
mkdir /var/log/mysql
mkdir /var/lib/mysql
mkdir /datadir
chown mysql.mysql -R /var/log/mysql /var/lib/mysql /datadir
我安装的是mysql的最新版本5.6
tar xf mysql5.6.12.tar.gz -C /usr/src
编译
cd /usr/src/mysql-5.6.12
1.我个人使用的下面参数
cmake -DCMAKE_ISTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DMYSQL_DATADIR=/datadir -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysql5.sock -DWITH_DEBUG=ON -DEXTRA_CHARSETS=ALL -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DSYSCONFDIR=/usr/local/mysql/etc -DWITH_READLINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
make && make install2.进行数据库的初始化
./usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/database --user=mysql
mkdir /usr/local/mysql/etc
chown -R mysql.mysql /usr/local/mysql
cp /usr/local/mysql/my.cnf /usr/local/mysql/etc/
cd /usr/local/mysql
vi etc/my.cnf
[root@kissing etc]# cat my.cnf | grep -v ^# | grep -v ^$[mysqld]
log_bin=mysql-bin
log-bin-index = mysql-bin.index
general_log = 1
general_log_file = /var/log/mysql/mysql.log
basedir = /usr/local/mysql
datadir = /database
port = 3306
socket = /var/run/mysqld/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld5
service mysqld5 start##########################################################################################
四、php的编译安装
yum groupinstall "X Software Development"
如果想让编译的php支持mcrypt、mhash扩展和libevent,直接编译安装
libevent-2.0.18-stable.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz -C /usr/src/lnmp/
cd libiconv-1.14/
./configure --prefix=/usr/local
make && make install
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
./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 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --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
%%%%%%%%错误总结%%%%%%%%%%%%错误总结%%%%%%%%错误总结%%%%%%%%%%错误总结%%%%%%%%%%%错误总结%%%%%
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
解决方法 yum install libxml* -y
-------------------------------------------------------
checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found.
解决方法 yum install -y libjpeg libjpeg-devel
-------------------------------------------------------------------------------
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
解决方法 yum install -y libpng libpng10 libpng10-devel libpng-devel
----------------------------------------------------------------------------------------------
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype.h not found
解决方法 yum install freetype-devel -y
---------------------------------------------------------------------------------
checking for ANSI C header files... (cached) yes
checking for LDAP support... yes
checking for LDAP Cyrus SASL support... yes
configure: error: Cannot find ldap.h
解决方法 yum install nss_ldap openldap openldap-clients openldap-devel openldap-servers
checking for LDAP support... yes
checking for LDAP Cyrus SASL support... yes
configure: error: Cannot find ldap libraries in /usr/lib.
解决方法cp -frp /usr/lib64/libldap* /usr/lib 即可
-----------------------------------------------------------------
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] Error 1
解决方法
cd libmcrypt-2.5.8/libltdl/
./configure --enable-ltdl-install
make && make install
------------------------------------------------------
--------------------------------------------------------------