1、数据库(db01)
ip:192.168.10.51、172.16.1.51
已提前安装好mariadb
1.1 创建数据库shop,字符集:utf-8
MariaDB [(none)]> create database shop charset utf8;
1.2 用户授权
MariaDB [(none)]> grant all on shop.* to 'shop'@'172.16.1.%' identified by '12345';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on shop.* to 'shop'@'localhost' identified by '12345';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
2、web服务端(web01)
ip:192.168.10.7、172.16.1.7
已提前安装好nginx、php
2.1 站点配置文件
[root@web01 ~]#vim /etc/nginx/conf.d/shop.conf
server {
listen 81;
server_name shop.com;
error_log /var/log/nginx/shop-error.log notice;
access_log /var/log/nginx/shop-access.log main;
root /app/code/shop;
location / {
index index.php;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
2.2 创建站点目录
站点目录:/app/code/shop
[root@web01 ~]#mkdir -p /app/code/shop
2.3 代码准备
电商平台代码官网:http://www.phpshe.com/down/phpshe1.8.rar
[root@web01 ~]#unzip phpshe1.8.zip
[root@web01 ~]#mv phpshe1.8/* /app/code/shop/
2.4 站点目录、文件权限
设置./config.php文件、./install目录、./data目录及其子目录的属主属组为nginx
[root@web01 ~]#chown -R nginx.nginx /app/code/shop/config.php
[root@web01 ~]#chown -R nginx.nginx /app/code/shop/install/
[root@web01 ~]#chown -R nginx.nginx /app/code/shop/data/
2.5重启nginx
[root@web01 ~]#systemctl restart nginx
2.6站点安装
浏览器打开:192.168.10.7:81
如下图:

浏览器打开:192.168.10.7:81/install
即进入安装流程:

填写相关信息:

点击完成:

2.7 php目录权限
/var/opt/remi/php74/lib/php/session/目录默认属主属组为root,如下:
[root@web01 ~]#ll -d /var/opt/remi/php74/lib/php/session/
drwxrwx--- 2 root apache 6 Jun 7 00:03 /var/opt/remi/php74/lib/php/session/
[root@web01 ~]#
该目录用于记录用户登录情况,默认权限会导致站点登录、注册的时候验证码出错,因此,该目录属主属组改为:nginx
[root@web01 ~]#chown -R nginx.nginx /var/opt/remi/php74/lib/php/session/
2.8 修改站点配置文件
配置文件:/app/code/shop/config.php
把$pe[‘url_model’]改成php
[root@web01 ~]#vim /app/code/shop/config.php
<?php
$pe['db_host'] = '172.16.1.51'; //数据库主机地址
$pe['db_name'] = 'shop'; //数据库名称
$pe['db_user'] = 'shop'; //数据库用户名
$pe['db_pw'] = '12345'; //数据库密码
$pe['db_coding'] = 'utf8';
$pe['url_model'] = 'php'; //url模式,可选项(pathinfo/pathinfo_safe/php)
$pe['h5_host'] = ''; //手机版网址
define('dbpre','pe_'); //数据库表前缀
?>
如果要做负载均衡的,则要做会话共享,使用redis
把/etc/opt/remi/php74/php-fpm.d/中的www.conf复制为session.conf
[root@web02 /app/code/shop]#cat /etc/opt/remi/php74/php-fpm.d/session.conf
....
listen = 127.0.0.1:9001
php_value[session.save_handler] = redis
php_value[session.save_path] = tcp://172.16.1.51:6379
此外,要给data目录做共享存储