商城环境搭建 lnmp

环境:

操作系统:centos6.8  2c  8g

Ip:47.91.211.209

商城环境:lnmp

nginx1.10.2  mysql-5.6.33  php5.6

Mysql: 官网:https://dev.mysql.com

Php:   官网:http://php.net

下载链接:http://am1.php.net/distributions/php-5.6.32.tar.gz

一.安装nginx

useradd nginx -u 1001

yum -y install zlib-devel  perl-devel perl-ExtUtils-Embed  gcc-c++ autoconf automake

tar -xzvf nginx1.10.2.tar.gz

 

安装GeoIP

cd GeoIP-1.4.8/

./configure

make && make install

 

安装 LuaJIT

cd LuaJIT-2.0.3

make && make install

 

安装nginx

cd nginx-1.10.2

 

./configure --group=nginx --prefix=/usr/local/nginx --add-module=../nginx-accesskey-2.0.3/ --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.10.9rc5/ --with-http_secure_link_module --with-http_random_index_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-pcre=../pcre-8.35 --error-log-path=/usr/local/nginx/logs/error.log --http-log-path=/usr/local/nginx/logs/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail_ssl_module --with-file-aio --with-ipv6 --add-module=../ngx_cache_purge-master --with-http_geoip_module --with-stream --with-zlib=../zlib-1.2.8/ --with-openssl=../openssl-1.0.2k

 

make

make install

 

mkdir /var/cache/nginx

添加加载库文件

vim /etc/ld.so.conf

添加/usr/local/lib/   ld.so.conf文件中

 

 

[root@HK-shop nginx-1.10.2]# ldconfig

测试nginx安装情况:

[root@HK-shop nginx-1.10.2]# /usr/local/nginx/sbin/nginx  -t

 

 

 

二.安装mysql

2.1、上传文件并进行解压

   cd /usr/local

       tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2.2、重命名

       mv  mysql-5.6.33-linux-glibc2.5-x86_64 mysql

2.3、添加用户和用户组

        groupadd mysql

        useradd -g mysql mysql

2.4、安装

       cd /usr/local/mysql/

       mkdir ./data/mysql

       chown -R mysql:mysql ./

       ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql

       cp support-files/mysql.server /etc/init.d/mysqld

       chmod 755 /etc/init.d/mysqld

       cp support-files/my-default.cnf /etc/my.cnf

 

2.5、修改启动脚本

    vi /etc/init.d/mysqld

       #修改项:

       basedir=/usr/local/mysql/

       datadir=/usr/local/mysql/data/mysql

 

2.6启动服务

     service mysqld start

2.7、加入环境变量

   vi /etc/profile

     增加内容:

     export PATH=$PATH:/usr/local/mysql/bin

     生效内容

       source /etc/profile

2.8测试连接

   cd /usr/local/mysql

       bin/mysql -uroot

 

   进入mysql

     mysql> use mysql

     mysql> update user set password=PASSWORD("root")where User="root";

     mysql> flush privileges;

     mysql> quit

2.9验证安装成功

    mysql -uroot -proot

    

 

    #(执行下面的语句*.*:所有库下的所有表   %:任何IP地址或主机都可以连接)

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

Mysql>FLUSH PRIVILEGES;

 

2.10、安装中出现错误问题

   -bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录

    解决: yum -y install perl perl-devel

   Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

    解决:yum -y install libaio-devel

 

 

 

 

 

 

 

三.安装php

 

yum install libxml2  libxml2-devel  bzip2  bzip2-devel libjpeg  libjpeg-devel libpng libpng-devel freetype freetype-devel  mcrypt  libmcrypt-devel

 

3.1安装libiconv

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz

tar -xzvf libiconv-1.15.tar.gz

cd libiconv-1.15

./configure --prefix=/usr/local/libiconv

make && make install

 

3.2 安装curl

wget https://curl.haxx.se/download/curl-7.57.0.tar.gz

tar -xzvf curl-7.57.0.tar.gz

cd curl-7.57.0

./configure --prefix=/usr/local/curl --with-ssl=/usr/local/ssl_1.0.1k

make && make install

 

3.3 安装php

wget http://am1.php.net/distributions/php-5.6.32.tar.gz

 

tar -xzvf  php-5.6.32.tar.gz

cd ../php-5.6.32

./configure  --enable-fpm --prefix=/usr/local/php-5.6 --with-libxml-dir --with-openssl=/usr/local/ssl_1.0.1k/ --with-zlib --with-bz2 --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-mysql --with-mysqli --with-pdo-mysql --with-curl=/usr/local/curl/ --with-iconv-dir=/usr/local/libiconv/ --with-mcrypt --enable-mbstring --with-freetype-dir  

 

make

make test

make install

 

mv /usr/local/php-5.6/etc/php-fpm.conf.default /usr/local/php-5.6/etc/php-fpm.conf

cp -a  php.ini-production /usr/local/php-5.6/etc/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod 755 /etc/init.d/php-fpm

 

修改配置文件:

vim /usr/local/php-5.6/etc/php.ini

open_basedir = .:/tmp/

date.timezone = "Asia/Shanghai"

3.4 php 启停

启动php:

/etc/init.d/php-fpm start

停止php

/etc/init.d/php-fpm stop

==================================================

 

编译过程中如果有报错:

安装PHP出现make: *** [sapi/cli/php] Error 1 解决办法

在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open'」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link iconv 函式库参数。 解决方法:编辑Makefile 大约77 行左右的地方: EXTRA_LIBS = ..... -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ..... -lcrypt -liconv 然后重新再次 make 即可。

 

或者用另一种办法

make ZEND_EXTRA_LIBS='-liconv'

ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/

 

 

   3.3 安装支持zend

wget http://downloads.zend.com/guard/7.0.0/zend-loader-php5.6-linux-x86_64_update1.tar.gz

mv zend-loader-php5.6-linux-x86_64  /usr/local/zend

 

修改php配置文件

vim /usr/local/php-5.6/etc/php.ini

在文件的最后添加下面内容

[Zend Guard]

zend_extension=/usr/local/zend/ZendGuardLoader.so

zend_loader.enable=1

zend_loader.disable_licensing=0

zend_loader.obfuscation_level_support=3

 

输入php -v命令查看Zend Guard Loader是否安装成功。(php5.6貌似不支持zend Crard Loader 需要再商榷)

重启nginx

 

 

 

 

 

 

 

 

 

3.5 Ecshop搭建商城问题

 

Ecshop安装过程中的的问题:cls_image::gd_version()和不支持JPEG

  在安装Ecshop的时候问题:

  1.Strict Standards: Non-static method cls_image::gd_version() should not be called statically in D:\X\www\ecshop\install\includes\lib_installer.php on line 31

  解决:找到install/includes/lib_installer.php中的第31   return cls_image::gd_version();然后在找到include/cls_image.php中的678行,发现gd_version()方法未声明静态static,所以会出错。这时候只要:

  1)将function gd_version()改成static function gd_version()即可。

  2)或者将install/includes/lib_installer.php中的第31return cls_image::gd_version();改成:

$p = new cls_image();return $p->gd_version();

  2.检测环境的时候提示:是否支持 JPEG是不支持的。

  解决:查看发现有libjpeg.lib库,GD2库也有,都加载了,也都正常。查看ecshop源代码发现install/includes/lib_installer.php中第100,JPEG写成了JPG,正确的应该是:

 

$jpeg_enabled = ($gd_info['JPEG Support']        === true) ? $_LANG['support'] : $_LANG['not_support'];

 

  为何说Ecshop写错了,因为我打印数组$gd_info的时候,里面的键名是:JPEG Support。而$gd_info数组里的值都是直接调用系统环境变量的。

 

  3.默认时区问题:Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in D:\X\www\ecshop\install\includes\lib_installer.php on line 225

  解决:方法1,将php.ini里是date.timezone前的";"去掉,改成:date.timezone = PRC;

  方法2,在页头使用 ini_set('date.timezone','Asia/Shanghai');

  方法3,在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');

 

转载于:https://www.cnblogs.com/heaven-xi/articles/9084922.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值