學習筆記----編譯搭建lnmp環境
一、首先搭建編譯環境
安裝gcc gcc-c++ libtermcap libtermcap-devel ncurese ncurses-devel zlib zlib-devel
二、編譯mysql
#tar -zxvf mysql-........
#cd mysql-......
#groupadd mysql
#useradd -g mysql mysql
#./configure --prefix=/usr/local/lnmp/mysql --with-client-ldflags=-all-static --with-mysql-ldflags=-all-static --enable-assmebler --with-unix-socket-path=/tmp/myslq.sock --with-extra-charsets=utf8,gbk,gb2312 --wtih-charset=utf8
#cp support-files/my-medium.cn /etc/my.cnf
#cd /usr/local/lnmp/mysql
#bin/mysql_install_db
#chown -R mysql var
#chgrp -R mysql .
#./bin/mysqld_safe &
三、編譯nginx
#tar -zxvf pcre-...
#cd pcre-...
#./configure&&make&&make install
編譯nginx前先安裝幾個工具:openssl openssl-devel zlib zlib-devel krb5-devel
#tar -zxvf nginx-...
#cd nginx
#groupadd www
#useradd -g www www
#./configure --user=www --group=www --prefix=/usr/local/lnmp/nginx
四、編譯php(fast-CGI)
1、安裝PHP依賴元件
libiconv freetype libpng libjpeg zlib libxml2 gd libmcrypt mhash
mcrypt
2、編譯安裝PHP 5.2.14所需的支援庫:
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
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
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
編譯mcrypt時出錯:
ecking for libmcrypt-config... /usr/local/bin/libmcrypt-config
checking for libmcrypt - version >= 2.5.0... no
*** Could not run libmcrypt test program, checking why...
*** The test program compiled, but did not run. This usually means
*** that the run-time linker is not finding LIBMCRYPT or finding the wrong
*** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your
*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
*** to the installed location Also, make sure you have run ldconfig if that
*** is required on your system
***
*** If you have an old version installed, it is best to remove it, although
*** you may also be able to get things to work by modifying LD_LIBRARY_PATH
configure: error: *** libmcrypt was not found
按上面的操作可以解決以上出現的問題
為PHP打更新檔:php-fpm
#gzip -d php-5.2.14-fpm-0.5.14.diff.gz
#patch -d php-5.2.14 -p1 < php-5.2.14-fpm-0.5.14.diff.gz
編譯PHP
#cd php-....
#./configure --prefix=/usr/local/lnmp/php --with-fpm-conf=/ etc/fpm-php.conf --with-confing-file-path=/usr/local/lnmp/php/etc --with-iconv=/usr/local/libiconv --with-freetype-dir --with-png-dir --with-libxml-dir --with-gd --enable-gd-native-ttf --enable-fastcgi --enable-fpm --enable-mbstring --with-openssl --with-mcrypt --with-xml --enable-inline-optimization
#cp /etc/fpm-php.conf /usr/local/lnmp/php/etc/fpm-php.conf (起備份作用)
#cp php.ini-dist /usr/local/lnmp/php/etc/php.ini
#vi /usr/local/lnmp/php/etc/fpm-php.conf
#cd /usr/local/lnmp/php/
#vi /etc/fpm-php.conf
Unix user of processes
<value name="user">www</value>
Unix group of processes
<value name="group">www</value>
Process manager settings
<value name="pm">
Sets style of controling worker process count.
Valid values are 'static' and 'apache-like'
<value name="style">static</value>
Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">128</value>
#./sbin/php-fpm start
配置nginx.conf 來釋出PHP
#cd /usr/local/lnmp/nginx/conf/
#vi nginx.conf
...................
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
預設這裡有一段配置,把它删了
include fastcgi_params;
}
.........................激活這段配置
#vi fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
#加入下面一段配置
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
五、安裝Zend Optimization3.3.3
#tar -zxvf Zend Optimization
#cd Zend Optimization
#./install.sh
可是啟動時就會報錯
[root@localhost php]# ./sbin/php-fpm restart
Shutting down php_fpm . done
Starting php_fpm PHP Warning: Zend Optimizer for PHP 5.2.x cannot be found (expected at '/usr/local/Zend/lib/Optimizer-3.0.0/php-5.2.x/ZendOptimizer.so') - try reinstalling the Zend Optimizer in Unknown on line 0
. done
在測試PHP中Zend會出現以下的情況

有可能是Zend的版本問題,但是我搞Zend Optimizer3.3.9還沒有搞定。搞了一天終于搞出來了。
#cd /usr/local/Zend/lib/
#ls 發現沒有Optimizer-3.0.0這個目錄,發現有Optimizer-3.3.3,試着将Optimizer-3.0.0重命名為Optimizer-3.3.3
#mv Optimizer-3.3.3 Optimizer-3.0.0
重新整理一下網頁終于搞定了。。
-------------------------------------------------------------------------
網上說直接用ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz來安裝
#tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
#mkdir -p /usr/local/Zend/lib
#cd ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp
#cp ZendOptimizer.so /usr/local/Zend/lib/ZendOptimizer.so
#cd /usr/local/lnmp/php/etc
#vi php.ini
..................... 在最後加上以下配置就OK
zend_optimizer.optimization_level=15
zend_extension=/usr/locaZendOptimizer.sol/Zend/lib/
------------------------可惜的是我沒有成功
六、測試LNMP環境,釋出DISCUZ論壇。
下載下傳UC1.5.1_UCH2.0_DZ7.2_SC_UTF8.zip和Discuz_7.2_SC_UTF8.zip