編譯安裝 LNMP架構及遇到的問題

一、 首先交代一個環境問題,編譯安裝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@kissingnginx-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@kissingnginx]# 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 install

2.進行數據庫的初始化

./usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/database --user=mysql

當看到兩個OK時,表示初始化成功

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 -ylibjpeg 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 -ylibpng 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

------------------------------------------------------


--------------------------------------------------------------

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章