一:准备工作
1.检查防火墙和SELinux是否关闭,如果二者不关闭,会严重影响实验。
关闭防火墙:iptables -F 临时清除
可靠关闭:systemctl stop firewalld
关闭selinux:setenforce 0
永久关闭:修改配置文件vim /etc/sysconfig/selinux
SELINUX=disabled
2.小米商务网站源码包-zip
二.安装需要的包
1. yum安装nginx
2 .yum 方式安装mariadb 、mariadb-server、php-mysql 、php-fpm
3 .下载小米商城源码,解压缩到/data/web目录,修改权限为nobody
mkdir -p /data/web
unzip -d /data/web xiaomi.zip
为了被盗后减少损失修改权限,将nginx的运行者改为nobody
cd /data/web
chown nobody:nobody /data/web
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/583278d9ac000ba5a07e56d311f24ac7.png" title="1.png" style="width:500px;height:125px;" alt="583278d9ac000ba5a07e56d311f24ac7.png" hspace="0" height="125" width="500" vspace="0" border="0" />
三、修改配置文件
1 .修改nginx 的主配置文件,把nginx.conf.default模板复制为配置文件nginx.conf进行修改,指定网站访问目录为/data/web ,并设置默认用户和配置与php-fpm 交互
cp nginx.conf.default nginx.conf
修改nginx.conf里的内容
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/77a43a7afc77c0837faf1ff5911665b0.png" title="1.png" style="width:350px;height:128px;" alt="77a43a7afc77c0837faf1ff5911665b0.png" hspace="0" height="128" width="350" vspace="0" border="0" />
650) this.width=650;" src="https://s1.51cto.com/oss/201711/02/ee1ad564a684bb2790e74d6edf85b8ce.png" title="1.png" style="width:400px;height:80px;" alt="ee1ad564a684bb2790e74d6edf85b8ce.png" hspace="0" height="80" width="400" vspace="0" border="0" />
重启nginx服务
systemctl restart nginx
2 、修改PHP.ini 中功能配置
vim /etc/php.ini
# 修改时钟配置 date.timezone= Asia/Shanghai
# 可以在php.ini 中设置short_open_tag= On
3.修改php-fpm的配置文件
vim /etc/php-fpm.d/www.conf
650) this.width=650;" src="https://s1.51cto.com/oss/201711/02/5d76ff51b084388123fd35d767ef947d.png" title="1.png" style="width:400px;height:117px;" alt="5d76ff51b084388123fd35d767ef947d.png" hspace="0" height="117" width="400" vspace="0" border="0" />
改完要重启systemctl restart php-fpm
四、访问应用配置修改(也在/etc/nginx/nginx.conf这个文件中)
1 、修改server 段加上默认工作路径,可访问到网站程序
650) this.width=650;" src="https://s3.51cto.com/oss/201711/02/e6e6715d1be99c99e32fc83d7d3271bc.png" title="1.png" style="width:380px;height:156px;" alt="e6e6715d1be99c99e32fc83d7d3271bc.png" hspace="0" height="156" width="380" vspace="0" border="0" />
2 、修改php 扩展解析文件路径 修改为
fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
650) this.width=650;" src="https://s4.51cto.com/oss/201711/02/f8431517025f521f9b7c22570d4c63d8.png" title="1.png" style="width:450px;height:84px;" alt="f8431517025f521f9b7c22570d4c63d8.png" hspace="0" height="84" width="450" vspace="0" border="0" />
到此配置文件大致已修改好,可以测试一下。
因为根目录在/data/web下,所以到此目录下。
cd /data/web
echo hello world > test.html
650) this.width=650;" src="https://s3.51cto.com/oss/201711/02/cbb35c69165d93871243f3df013722b4.png" title="1.png" alt="cbb35c69165d93871243f3df013722b4.png" />
五、 启动数据库,并创建数据库
systemctl start mariadb
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/399e068a4188b526b4b4932bca9f914e.png" title="1.png" style="width:500px;height:256px;" alt="399e068a4188b526b4b4932bca9f914e.png" hspace="0" height="256" width="500" vspace="0" border="0" />
六、网站部署和验证
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/9b337da08615f8a5a17fce9855f67863.png" title="1.png" style="width:500px;height:262px;" alt="9b337da08615f8a5a17fce9855f67863.png" hspace="0" height="262" width="500" vspace="0" border="0" />
1、打开http://ip/ebak 后台恢复系统 账号 admin密码 123456
2、配置连接数据库并连接到数据库
vim /data/web/data/config.php
650) this.width=650;" src="https://s3.51cto.com/oss/201711/02/5fb3b088141eea2042a5558c2e093687.png" title="1.png" style="width:500px;height:151px;" alt="5fb3b088141eea2042a5558c2e093687.png" hspace="0" height="151" width="500" vspace="0" border="0" />
3、恢复网站数据信息,并验证http://ip/index.php能正常访问
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/03a3665b5f05c697d4fd62d892a47c0a.png" title="1.png" style="width:500px;height:144px;" alt="03a3665b5f05c697d4fd62d892a47c0a.png" hspace="0" height="144" width="500" vspace="0" border="0" />
650) this.width=650;" src="https://s4.51cto.com/oss/201711/02/1494c023d6b449bc14c5222dbe1a9a6d.png" title="2.png" style="width:500px;height:92px;" alt="1494c023d6b449bc14c5222dbe1a9a6d.png" hspace="0" height="92" width="500" vspace="0" border="0" />
数据恢复完成后,访问就可进入如下页面
650) this.width=650;" src="https://s2.51cto.com/oss/201711/02/3ed253cd9eedb6aafacdc156a7840149.png" title="1.png" style="width:500px;height:243px;" hspace="0" height="243" width="500" vspace="0" border="0" alt="3ed253cd9eedb6aafacdc156a7840149.png" />
4、登陆后台,并查看网站日常操作页面
650) this.width=650;" src="https://s3.51cto.com/oss/201711/02/76a1aaacebc53ae4e000034abd021036.png" title="1.png" style="width:500px;height:299px;" hspace="0" height="299" width="500" vspace="0" border="0" alt="76a1aaacebc53ae4e000034abd021036.png" />
650) this.width=650;" src="https://s5.51cto.com/oss/201711/02/1955361bee282c9ea75cb8004ab524c1.png" title="1.png" style="width:400px;height:417px;" hspace="0" height="417" width="400" vspace="0" border="0" alt="1955361bee282c9ea75cb8004ab524c1.png" />
到此lnmp搭建成功。
本文出自 “13162732” 博客,请务必保留此出处http://13172732.blog.51cto.com/13162732/1978542
实现基于LNMP 的电子商务网站
原文地址:http://13172732.blog.51cto.com/13162732/1978542