学习笔记----编译搭建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
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
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/
/sbin/ldconfig
./configure
make
make install
cd ../
编译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