Nginx(一)初始環境的安裝(php5.3+mysql5.1+fastcgi...)

相關參考資源
http://www.lnmp.org/index.html                         \\LNMP一鍵安裝包
http://www.howtocn.org/nginx                           \\Nginx模塊參考手冊中文版
http://blog.s135.com/nginx_php_v6/                      \\張宴寫的nginx文章
http://www.nginx.com.cn/                                 \\nginx中文網

如下爲我寫的。。。。。。

yum -y remove httpd*
yum -y remove mysql*
yum -y remove php*

時間同步
/usr/sbin/ntpdate 0.rhel.pool.ntp.org > /dev/null 2>&1 ; /sbin/clock -w > /dev/null 2>&1

 yum --enablerepo=remi -y install gcc gcc-c++ automake autoconf libtool

 yum -y --enablerepo=remi install gd freetype gd-devel.x86_64 freetype.x86_64 \
 freetype-devel.x86_64 libjpeg.x86_64 libjpeg-devel.x86_64  \
 libpng.x86_64 libpng-devel.x86_64 libxml2.x86_64 libxml2-devel.x86_64 \
 zlib.x86_64  zlib-devel.x86_64 libevent.x86_64 libevent-devel.x86_64 \
 bzip2.x86_64 bzip2-devel.x86_64 glib.x86_64 glib-devel.x86_64 glib2.x86_64 glib2-devel.x86_64
 yum --enablerepo=remi -y install libc-client.x86_64  libc-client-devel.x86_64

 yum --enablerepo=remi -y install net-snmp.x86_64 net-snmp-devel.x86_64 \
 net-snmp-libs.x86_64 net-snmp-utils.x86_64 net-snmp-perl.x86_64

 ln -s /usr/lib64/libpng.so /usr/lib/
 ln -s /usr/lib64/libc-client.a /usr/lib/
 我的是64位系統所以要做這一步


相關軟件包的下載,有必要時可到鏈接處找最新的安裝包

mkdir /usr/local/src/lnmp
wget -c http://nginx.org/download/nginx-0.9.1.tar.gz
wget -c http://cn2.php.net/get/php-5.3.3.tar.gz/from/cn.php.net/mirror
wget -c http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.53.tar.gz/from/http://mysql.ntu.edu.tw/
wget -c http://soft.vpser.net/web/pdo/PDO_MYSQL-1.0.2.tgz
wget -c http://pecl.php.net/get/memcache-3.0.5.tgz
wget -c http://soft.vpser.net/web/pcre/pcre-8.10.tar.gz
wget -c http://soft.vpser.net/web/libiconv/libiconv-1.13.tar.gz
wget -c http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
wget -c http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz
wget -c http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz
wget -c http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2

Install

cd /usr/local/src/lnmp;cur_dir=$(pwd)
cd $cur_dir; tar zxvf libiconv-1.13.tar.gz
cd libiconv-1.13/
./configure --prefix=/usr/local
make && make install

cd $cur_dir
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 $cur_dir
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
ldconfig

cd $cur_dir
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install
cd ../

Mysql的安裝

cd $cur_dir
tar -zxvf mysql-5.1.53.tar.gz
cd mysql-5.1.53/
groupadd mysql
useradd -g mysql mysql
./configure --prefix=/usr/local/mysql --sysconfdir=/etc \
 --with-extra-charsets=all \
 --with-charset=utf8 \
 --with-plugins=all \
 --with-big-tables \
 --with-embedded-server \
 --enable-local-infile \
 --enable-assembler \
 --with-mysqld-user=mysql

 ###如果報configure: error: No curses/termcap library found
 #yum --enablerepo=remi -y install ncurses.x86_64 ncurses-devel.x86_64

make && make install
cd ../
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
chown -R mysql.mysql /usr/local/mysql/
sed -i 's/skip-locking/skip-external-locking/g' /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 345 mysql on
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
echo "/usr/local/lib" >>/etc/ld.so.conf
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ldconfig
/etc/init.d/mysql start
/etc/init.d/mysql restart

php+fast-cgi的安裝, 5.3.3 源碼中開始包含 php-fpm,不用專門再打補丁了,只需要解開源碼直接configure,關於php-fpm的編譯參數有 –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-libevent-dir=libevent位置。

cd $cur_dir
tar zxvf php-5.3.3.tar.gz
cd php-5.3.3
./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-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--with-mhash \
--with-mcrypt \
--with-curl \
--with-curlwrappers \
--with-openssl \
--with-gettext \
--with-iconv-dir \
--with-libxml-dir \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-libevent-dir \
--enable-inline-optimization \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-zip \
--enable-sockets 

#Kerberos libraries not found  ,解決方法是,ln -s /usr/lib64/ /usr/kerberos/lib

make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/php/etc/php.ini
cd ../
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm

cd $cur_dir
tar -zxvf memcache-3.0.5.tgz
cd memcache-3.0.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../

cd $cur_dir
tar -jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
mkdir -p /usr/local/eaccelerator_cache
chmod 777 /usr/local/eaccelerator_cache

cd $cur_dir
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
cd ../

sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/g' /usr/local/php5/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php5/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php5/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php5/etc/php.ini
sed -i '262i output_buffering = On' /usr/local/php5/etc/php.ini

#-------------------------編輯php.ini文件做如下修改-------------------------------------#
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "memcache.so"
extension = "pdo_mysql.so"

[eaccelerator]             
;#######################zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

#--------------------------配置php-fpm.conf,如下操作--------------------------------------#
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf

[global]
pid = /usr/local/php5/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = www
group = www
pm = dynamic
pm.max_children = 2000
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35

groupadd www
useradd -g www www
mkdir -p /var/www/html
chown www.www /var/www/html/

cd $cur_dir
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10/
./configure
make && make install
cd ../

tar zxvf nginx-0.9.1.tar.gz
cd nginx-0.9.1
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../

 cat >/var/www/html/phpinfo.php<<eof
<?php
phpinfo();
?>
eof


給PHP加速,eAccelerator配置和使用指南
http://www.toplee.com/blog/100.html#pp2    
http://eaccelerator.net/wiki/InstallFromSource         //安裝文檔
http://eaccelerator.net/wiki/Settings                  //配置說明

php-fpm管理
kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid`               //終止
/usr/local/php5/sbin/php-fpm                                       //啓動
kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`          //重啓
kill -SIGUSR1 `cat /usr/local/php/var/run/php-fpm.pid`          //日誌

nginx管理
/usr/local/nginx/sbin/nginx                                                       //啓動
/usr/local/nginx/sbin/nginx -s reload                                            //平滑重啓
/usr/local/nginx/sbin/nginx -t                                                   //測試

Others
nginx0.8.52+php5.3.3
http://addcn.blogbus.com/tag/php5.3.3/

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