首页 > 代码库 > linux下基于电商平台lnmp部署

linux下基于电商平台lnmp部署

实验环境:
system:centos 6.5
nginx:tengine-1.5.1
php:php-5.4.25
mysql:mysql-5.5.38

 

[root@showip 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
[root@showip opt]# ln -s /usr/lib64/* /usr/lib/


1.nginx 安装
[root@showip opt]# tar zxf pcre-8.34.tar.gz
[root@showip opt]# cd pcre-8.34
[root@showip pcre-8.34]# ./configure
[root@showip pcre-8.34]# make && make install
[root@showip opt]# useradd nginx -s /sbin/nologin
[root@showip opt]# tar zxf tengine-1.5.1.tar.gz
[root@showip opt]# cd tengine-1.5.1
[root@showip 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
[root@showip tengine-1.5.1]# make && make install
[root@showip tengine-1.5.1]# ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
[root@showip tengine-1.5.1]# mv /opt/nginxd /etc/init.d/   # nginxd启动脚本在附件
[root@showip tengine-1.5.1]# chmod 700 /etc/init.d/nginxd
[root@showip tengine-1.5.1]# chkconfig --add nginxd
[root@showip tengine-1.5.1]# chkconfig nginxd on


2.php安装
[root@showip opt]# tar zxf php-5.4.25.tar.gz
[root@showip opt]# cd php-5.4.25
[root@showip 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
[root@showip php-5.4.25]# make && make install
[root@showip php-5.4.25]# cp php.ini-production /usr/local/php/etc/php.ini
[root@showip php-5.4.25]# rm -rf /etc/php.ini
[root@showip php-5.4.25]# ln -s /usr/local/php/etc/php.ini  /etc/php.ini
[root@showip php-5.4.25]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@showip php-5.4.25]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@showip php-5.4.25]# chmod o+x /etc/rc.d/init.d/php-fpm
[root@showip php-5.4.25]# chkconfig --add php-fpm
[root@showip php-5.4.25]# chkconfig php-fpm on


3.mysql安装
[root@showip opt]# useradd mysql -s /sbin/nologin
[root@showip opt]# tar zxf mysql-5.5.38.tar.gz
[root@showip opt]# cd mysql-5.5.38
[root@showip 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
[root@showip mysql-5.5.38]# make && make install
[root@showip mysql-5.5.38]# mkdir /var/lib/mysql
[root@showip mysql-5.5.38]# mkdir /var/log/mysql
[root@showip mysql-5.5.38]# chown -R mysql:mysql /var/lib/mysql
[root@showip mysql-5.5.38]# chown -R mysql:mysql /var/log/mysql
[root@showip 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
[root@showip mysql-5.5.38]# cp support-files/my-medium.cnf /etc/my.cnf
[root@showip 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
[root@showip mysql-5.5.38]# cp support-files/mysql.server /etc/rc.d/init.d/mysql
[root@showip mysql-5.5.38]# chmod o+x /etc/rc.d/init.d/mysql
[root@showip mysql-5.5.38]# chkconfig --add mysql
[root@showip mysql-5.5.38]# chkconfig mysql on
[root@showip mysql-5.5.38]# ln /usr/local/mysql/bin/mysql /usr/bin/
[root@showip mysql-5.5.38]# ln /usr/local/mysql/bin/mysqladmin /usr/bin/
[root@showip mysql-5.5.38]# ln /usr/local/mysql/bin/mysqldump /usr/bin/


4.php插件安装
(1)apc
[root@showip opt]# tar zxf APC-3.1.13.tgz
[root@showip opt]# cd APC-3.1.13
[root@showip APC-3.1.13]# /usr/local/php/bin/phpize
[root@showip APC-3.1.13]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-apc --enable-mmap --enable-apc-spinlocks --disable-apc-pthreadmutex
[root@showip APC-3.1.13]# make && make install
[root@showip APC-3.1.13]# echo "extension = apc.so" >> /usr/local/webapps/php/etc/php.ini
(2)memcache
[root@showip opt]# tar zxf memcache-2.2.7.tgz
[root@showip opt]# cd memcache-2.2.7
[root@showip memcache-2.2.7]# /usr/local/php/bin/phpize
[root@showip memcache-2.2.7]# ./configure  --with-php-config=/usr/local/php/bin/php-config
[root@showip memcache-2.2.7]# make && make install
[root@showip memcache-2.2.7]# echo "extension = memcache.so" >> /usr/local/php/etc/php.ini
(3)redis
[root@showip opt]# unzip phpredis-master.zip
[root@showip opt]# cd phpredis-master
[root@showip phpredis-master]# /usr/local/php/bin/phpize
[root@showip phpredis-master]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@showip phpredis-master]# make && make install
[root@showip phpredis-master]# echo "extension = redis.so" >> /usr/local/php/etc/php.ini
(4)imagick
[root@showip opt]# tar zxf ImageMagick.tar.gz
[root@showip opt]# cd ImageMagick-6.8.9-10/
[root@showip ImageMagick-6.8.9-10]# ./configure LDFLAGS="-L/usr/lib" CPPFLAGS="-I/usr/include" --prefix=/usr/local/ImageMagick --enable-shared --enable-lzw --disable-openmp
[root@showip opt]# tar zxf imagick-3.1.0RC2.tgz
[root@showip opt]# cd imagick-3.1.0RC2
[root@showip imagick-3.1.0RC2]# /usr/local/php/bin/phpize
[root@showip imagick-3.1.0RC2]# ln -s /usr/local/ImageMagick/include/ImageMagick-6 /usr/local/ImageMagick/include/ImageMagick
[root@showip 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/
[root@showip imagick-3.1.0RC2]# make && make install
[root@showip imagick-3.1.0RC2]# echo "extension = imagick.so" >> /usr/local/php/etc/php.ini
(5)magickwand
[root@showip opt]# tar zxf MagickWandForPHP-1.0.9-2.tar.gz
[root@showip opt]# cd MagickWandForPHP-1.0.9
[root@showip MagickWandForPHP-1.0.9]# /usr/local/php/bin/phpize
[root@showip 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/
[root@showip MagickWandForPHP-1.0.9]# make && make install
[root@showip MagickWandForPHP-1.0.9]# echo "extension = magickwand.so" >> /usr/local/php/etc/php.ini
(6)eaccelerator
[root@showip opt]# tar zxf  eaccelerator-eaccelerator-42067ac.tar.gz
[root@showip opt]# cd eaccelerator-eaccelerator-42067ac
[root@showip eaccelerator-eaccelerator-42067ac]# /usr/local/php/bin/phpize
[root@showip eaccelerator-eaccelerator-42067ac]# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
[root@showip eaccelerator-eaccelerator-42067ac]# make && make install
[root@showip eaccelerator-eaccelerator-42067ac]# mkdir /tmp/eaccelerator
[root@showip eaccelerator-eaccelerator-42067ac]# chmod 777 /tmp/eaccelerator/
[root@showip eaccelerator-eaccelerator-42067ac]# echo "extension = eaccelerator.so" >> /usr/local/php/etc/php.ini
(7)zend
[root@showip opt]# tar zxf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
[root@showip opt]# mkdir /usr/local/zend
[root@showip opt]# cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so /usr/local/zend/
[root@showip 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.测试
[root@showip ~]# /etc/init.d/php-fpm start
[root@showip ~]# /etc/init.d/mysql start
[root@showip ~]# /etc/init.d/nginxd start技术分享
nginx访问正常
[root@showip ~]# echo -e "<?php\nphpinfo();\n?>" > /usr/local/nginx/html/phpinfo.php
[root@showip 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扩展

 

 

 

 

 

 

 

本文出自 “Linux艺术(Q群:1991706)” 博客,请务必保留此出处http://304076020.blog.51cto.com/7503470/1604002

linux下基于电商平台lnmp部署