实验环境:
system:centos 6.5
nginx:tengine-1.5.1
php:php-5.4.25
mysql:mysql-5.5.38
[[email protected] opt]# yum install -y make cmake apr* autoconf automake curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd gd-devel gettext gettext-devel kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch libxslt-devel lua-devel GeoIP GeoIP-devel t1lib-devel libicu-devel libmcrypt-devel
[[email protected] opt]# ln -s /usr/lib64/* /usr/lib/
1.nginx 安装
[[email protected] opt]# tar zxf pcre-8.34.tar.gz
[[email protected] opt]# cd pcre-8.34
[[email protected] pcre-8.34]# ./configure
[[email protected] pcre-8.34]# make && make install
[[email protected] opt]# useradd nginx -s /sbin/nologin
[[email protected] opt]# tar zxf tengine-1.5.1.tar.gz
[[email protected] opt]# cd tengine-1.5.1
[[email protected] tengine-1.5.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sysguard_module --with-http_concat_module --enable-mods-shared=all
[[email protected] tengine-1.5.1]# make && make install
[[email protected] tengine-1.5.1]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
[[email protected] tengine-1.5.1]# mv /opt/nginxd /etc/init.d/ # nginxd启动脚本在附件
[[email protected] tengine-1.5.1]# chmod 700 /etc/init.d/nginxd
[[email protected] tengine-1.5.1]# chkconfig --add nginxd
[[email protected] tengine-1.5.1]# chkconfig nginxd on
2.php安装
[[email protected] opt]# tar zxf php-5.4.25.tar.gz
[[email protected] opt]# cd php-5.4.25
[[email protected] php-5.4.25]# ./configure --prefix=/usr/local/php --sysconfdir=/usr/local/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --disable-cgi --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/ext --enable-calendar --with-curl --enable-ftp --with-gd --enable-intl --enable-mbstring --with-mcrypt --with-mysql --with-pdo-mysql --enable-sockets --enable-zip --with-pcre-dir --enable-mysqlnd --with-iconv=/usr/local/libiconv --with-jpeg-dir=DIR --with-png-dir=DIR --with-zlib-dir=DIR --with-xpm-dir=DIR --with-freetype-dir=DIR --with-t1lib=DIR --enable-gd-native-ttf --enable-gd-jis-conv --with-iconv
[[email protected] php-5.4.25]# make && make install
[[email protected] php-5.4.25]# cp php.ini-production /usr/local/php/etc/php.ini
[[email protected] php-5.4.25]# rm -rf /etc/php.ini
[[email protected] php-5.4.25]# ln -s /usr/local/php/etc/php.ini /etc/php.ini
[[email protected] php-5.4.25]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] php-5.4.25]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[[email protected] php-5.4.25]# chmod o+x /etc/rc.d/init.d/php-fpm
[[email protected] php-5.4.25]# chkconfig --add php-fpm
[[email protected] php-5.4.25]# chkconfig php-fpm on
3.mysql安装
[[email protected] opt]# useradd mysql -s /sbin/nologin
[[email protected] opt]# tar zxf mysql-5.5.38.tar.gz
[[email protected] opt]# cd mysql-5.5.38
[[email protected] mysql-5.5.38]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DWITH_SSL=system -DWITH_DEBUG=0
[[email protected] mysql-5.5.38]# make && make install
[[email protected] mysql-5.5.38]# mkdir /var/lib/mysql
[[email protected] mysql-5.5.38]# mkdir /var/log/mysql
[[email protected] mysql-5.5.38]# chown -R mysql:mysql /var/lib/mysql
[[email protected] mysql-5.5.38]# chown -R mysql:mysql /var/log/mysql
[[email protected] mysql-5.5.38]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --pid-file=/var/lib/mysql/mysql.pid --datadir=/var/lib/mysql/ --basedir=/usr/local/mysql
[[email protected] mysql-5.5.38]# cp support-files/my-medium.cnf /etc/my.cnf
[[email protected] mysql-5.5.38]# vi /etc/my.cnf
[client]
socket = /var/lib/mysql/mysql.sock
# The MySQL server
[mysqld]
socket = /var/lib/mysql/mysql.sock
log-error = /var/log/mysql/mysql-error.log
pid-file = /var/lib/mysql/mysql.pid
character-set-server = utf8
[[email protected] mysql-5.5.38]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
[[email protected] mysql-5.5.38]# chmod o+x /etc/rc.d/init.d/mysql
[[email protected] mysql-5.5.38]# chkconfig --add mysql
[[email protected] mysql-5.5.38]# chkconfig mysql on
[[email protected] mysql-5.5.38]# ln /usr/local/mysql/bin/mysql /usr/bin/
[[email protected] mysql-5.5.38]# ln /usr/local/mysql/bin/mysqladmin /usr/bin/
[[email protected] mysql-5.5.38]# ln /usr/local/mysql/bin/mysqldump /usr/bin/
4.php插件安装
(1)apc
[[email protected] opt]# tar zxf APC-3.1.13.tgz
[[email protected] opt]# cd APC-3.1.13
[[email protected] APC-3.1.13]# /usr/local/php/bin/phpize
[[email protected] APC-3.1.13]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-apc --enable-mmap --enable-apc-spinlocks --disable-apc-pthreadmutex
[[email protected] APC-3.1.13]# make && make install
[[email protected] APC-3.1.13]# echo "extension = apc.so" >> /usr/local/webapps/php/etc/php.ini
(2)memcache
[[email protected] opt]# tar zxf memcache-2.2.7.tgz
[[email protected] opt]# cd memcache-2.2.7
[[email protected] memcache-2.2.7]# /usr/local/php/bin/phpize
[[email protected] memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config
[[email protected] memcache-2.2.7]# make && make install
[[email protected] memcache-2.2.7]# echo "extension = memcache.so" >> /usr/local/php/etc/php.ini
(3)redis
[[email protected] opt]# unzip phpredis-master.zip
[[email protected] opt]# cd phpredis-master
[[email protected] phpredis-master]# /usr/local/php/bin/phpize
[[email protected] phpredis-master]# ./configure --with-php-config=/usr/local/php/bin/php-config
[[email protected] phpredis-master]# make && make install
[[email protected] phpredis-master]# echo "extension = redis.so" >> /usr/local/php/etc/php.ini
(4)imagick
[[email protected] opt]# tar zxf ImageMagick.tar.gz
[[email protected] opt]# cd ImageMagick-6.8.9-10/
[[email protected] ImageMagick-6.8.9-10]# ./configure LDFLAGS="-L/usr/lib" CPPFLAGS="-I/usr/include" --prefix=/usr/local/ImageMagick --enable-shared --enable-lzw --disable-openmp
[[email protected] opt]# tar zxf imagick-3.1.0RC2.tgz
[[email protected] opt]# cd imagick-3.1.0RC2
[[email protected] imagick-3.1.0RC2]# /usr/local/php/bin/phpize
[[email protected]p imagick-3.1.0RC2]# ln -s /usr/local/ImageMagick/include/ImageMagick-6 /usr/local/ImageMagick/include/ImageMagick
[[email protected] imagick-3.1.0RC2]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/ImageMagick/
/php-config --with-imagick=/usr/local/ImageMagick/
[[email protected] imagick-3.1.0RC2]# make && make install
[[email protected] imagick-3.1.0RC2]# echo "extension = imagick.so" >> /usr/local/php/etc/php.ini
(5)magickwand
[[email protected] opt]# tar zxf MagickWandForPHP-1.0.9-2.tar.gz
[[email protected] opt]# cd MagickWandForPHP-1.0.9
[[email protected] MagickWandForPHP-1.0.9]# /usr/local/php/bin/phpize
[[email protected] MagickWandForPHP-1.0.9]# ./configure --prefix=/usr/local/magickwand --enable-shared --with-php-config=/usr/local/php/bin/php-config --with-magickwand=/usr/local/ImageMagick/
[[email protected] MagickWandForPHP-1.0.9]# make && make install
[[email protected] MagickWandForPHP-1.0.9]# echo "extension = magickwand.so" >> /usr/local/php/etc/php.ini
(6)eaccelerator
[[email protected] opt]# tar zxf eaccelerator-eaccelerator-42067ac.tar.gz
[[email protected] opt]# cd eaccelerator-eaccelerator-42067ac
[[email protected] eaccelerator-eaccelerator-42067ac]# /usr/local/php/bin/phpize
[[email protected] eaccelerator-eaccelerator-42067ac]# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
[[email protected] eaccelerator-eaccelerator-42067ac]# make && make install
[[email protected] eaccelerator-eaccelerator-42067ac]# mkdir /tmp/eaccelerator
[[email protected] eaccelerator-eaccelerator-42067ac]# chmod 777 /tmp/eaccelerator/
[[email protected] eaccelerator-eaccelerator-42067ac]# echo "extension = eaccelerator.so" >> /usr/local/php/etc/php.ini
(7)zend
[[email protected] opt]# tar zxf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
[[email protected] opt]# mkdir /usr/local/zend
[[email protected] opt]# cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so /usr/local/zend/
[[email protected] opt]# vi /usr/local/php/etc/php.ini
[Zend Optimizer]
zend_loader.enable = 1
[Zend Guard]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
5.测试
[[email protected] ~]# /etc/init.d/php-fpm start
[[email protected] ~]# /etc/init.d/mysql start
[[email protected] ~]# /etc/init.d/nginxd start
nginx访问正常
[[email protected] ~]# echo -e "<?php\nphpinfo();\n?>" > /usr/local/nginx/html/phpinfo.php
[[email protected] html]# vi mysql.php
<?php
$conn = mysql_connect("127.0.0.1","root","123456") or die("connect err: ".mysql_error());
echo "The success of MySQL links ! ";
?>
mysql链接成功
apc扩展
memcache扩展
redis扩展
imagick扩展
magickwand扩展
eaccelerator 扩展
ZendGuardLoader扩展