项目实战:ecshop

项目实战:ecshop

准备 LNMP 环境

准备 Nginx
bash 复制代码
# 安装
[root@server ~ 22:17:36]# systemctl enable nginx.service --now
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@server ~ 22:18:44]# echo "nginx test page" > /usr/share/nginx/html/index.html 
[root@server ~ 22:19:27]# vim /etc/hosts
#添加  www.server.cloud

#测试
[root@server ~ 22:19:58]# curl http://www.server.cloud/
nginx test page
准备 Mariadb
bash 复制代码
[root@server ~ 22:22:26]# yum install -y mariadb-server
[root@server ~ 22:22:26]# systemctl enable mariadb.service --now

# 安全初始化
# 设置root密码为123
# 删除匿名用户
# 删除测试数据库
[root@server ~ 22:23:02]# mysql_secure_installation
准备 PHP
bash 复制代码
[root@server ~ 22:25:29]# yum install -y php php-fpm
[root@server ~ 22:25:29]# systemctl enable php-fpm.service --now
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

# 配置虚拟主机
[root@server ~ 22:25:58]# vim /etc/nginx/conf.d/www.server.cloud.conf
server {
    listen       80;
    listen       [::]:80;
    server_name  www.server.cloud;
    root         /usr/share/nginx/html;
    index index.php;
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

[root@server ~ 22:27:10]# systemctl restart nginx.service 

# 准备测试页面
[root@server ~ 22:27:29]# echo "<?php echo 'PHP Test Page'.\"\n\"; ?>" > /usr/share/nginx/html/test.php

# 客户端测试
[root@client ~ 22:31:21]# curl http://www.server.cloud/test.php
PHP Test Page

准备数据库

bash 复制代码
[root@server ~ 22:34:10]# mysql -u root -p
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> create database ecshop;

MariaDB [(none)]> create user ecshop@localhost identified by '123';

MariaDB [(none)]> grant all privileges on ecshop.* to ecshop@localhost;

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit;

准备 ecshop 站点

准备 ecshop 站点数据文件,这里使用 ECShop_V4.1.20 版本。

bash 复制代码
# 上传ECShop_V4.1.20_UTF8.zip
[root@server ~ 22:39:35]# rz
[root@server ~ 22:39:35]# ls
anaconda-ks.cfg  ECShop_V4.1.20_UTF8.zip

#解压
[root@server ~ 22:40:22]# unzip ECShop_V4.1.20_UTF8.zip 
[root@server ~ 22:40:22]# ls
anaconda-ks.cfg
ECShop_V4.1.20_UTF8_release20250416
ECShop_V4.1.20_UTF8.zip

#备份html然后复制
[root@server ~ 22:41:18]# mv /usr/share/nginx/html{,.ori}
[root@server ~ 22:41:44]# cp -a ECShop_V4.1.20_UTF8_release20250416/source/ecshop /usr/share/nginx/html

#修改用户用户组
[root@server ~ 22:42:40]# chown nginx:nginx -R /usr/share/nginx/html

# 安装站点需要的各种扩展包
[root@server ~ 22:42:45]#yum install -y php-gd php-common php-pear php-mbstring php-mcrypt php-mysqlnd

# 修改 php-fpm运行用户身份
[root@server ~ 22:42:58]# vim /etc/php-fpm.d/www.conf 
# 更改以下两条记录
# user = apache
user = nginx

# group = apache
group = nginx

[root@server ~ 22:46:46]# chown nginx:nginx -R /var/lib/php/
[root@server ~ 22:47:14]# systemctl restart nginx.service php-fpm.service 

配置过程

客户端登录http://www.server.cloud






相关推荐
zzzzzz3109 小时前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode10 小时前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220701 天前
如何搭建本地yum源(上)
运维
A小辣椒2 天前
TShark:Wireshark CLI 功能
linux
A小辣椒2 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao3 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334663 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪3 天前
linux 拷贝文件或目录到指定的位置
linux
大树884 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai