# uhs_plugin **Repository Path**: open_uhaveshop/uhs_plugin ## Basic Information - **Project Name**: uhs_plugin - **Description**: 独立化部署-插件版 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-24 - **Last Updated**: 2025-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 关于 UHaveShop > Uhaveshop优海独立站开发搭建制作,外贸网站建设推广公司,提供跨境电商独立站定制推广、B2B网站建设推广、B2C外贸网站搭建推广、跨境电商企业外贸网站建设推广服务,多年外贸公司网站建站服务经验,为深圳、香港、台湾、广州、中山、佛山、东莞、珠海、北京、上海等跨境电商企业服务,提供定制化的独立站建设、外贸B2B网站建设、外贸B2C网站建设服务,深圳B2B、B2C外贸网站建设公司 > 咨询电话:0755-8672-1169 > > 联系我们:info@uhaveshop.com ## 1. 项目目录 ``` |-- uhs_plugin |-- app | |-- Console | | |-- Conmmands | | |-- Kernel.php ## 避免任务重复,日志目录:storage/logs/ | |-- Event | |-- Evceptions | |-- Http | | |-- Controllers ## 控制器,按业务模块分类 | | |-- Middleware | | |-- Proxy | | |-- Kernel.php | |-- Jobs | |-- Listeners | |-- Mail | |-- Models ## 模型,按业务模块分类 | |-- Notifications | |-- Observers ## 观察者,按业务模块分类 | |-- Providers | |-- Utils ## 助手工具 | |-- Option.php | |-- User.php |-- bootstrap |-- config ## 项目配置发布目录 |-- database | |-- factories | |-- migrations ## 迁移文件,本地开发可进行更新,部署测试及生产后不允许更新迁移文件 | |-- seeds |-- public | |-- assets | |-- css | |-- files ## 导出文件模版 | |-- js | |-- index.php | |-- logo.png |-- resources | |-- js | |-- lang | |-- node ## node服务目录 | |-- views | | |-- Controllers ## 控制器,按业务模块分类 | | |-- Middleware | | |-- Proxy | | |-- Kernel.php |-- routes | |-- api.php ## API路由 | |-- channels.php | |-- console.php | |-- web.php ## 默认关闭,404 |-- storage |-- tests |-- vender |-- .env.example ## 环境配置模版,新的环境变量请及时加入该模版 |-- .gitignore |-- artisan |-- CHANGELOG.md |-- composer.json |-- composer.lock |-- phpunit.xml |-- readme.me |-- server.php |-- webpack.mix.js ``` ## 2. 开始安装 ### 非集成环境安装uhs_plugin(Ubuntu20.04) 以下命令安装环境如下 - nginx1.18 - mysql8.0 - php7.4 - redis5.5 - composer2.0 ### 环境安装 1. 更新系统 ```shell sudo apt update && sudo apt upgrade ``` 2. 安装nginx ```shell sudo apt install nginx sudo nginx -v sudo systemctl status nginx ``` 3. 安装mysql ```shell sudo apt install mysql-server mysql-client sudo mysql -v sudo systemctl status mysql sudo mysql_secure_installation sudo mysql -uroot -p ``` 4. 安装php ```shell sudo apt install php7.4 php7.4-bcmath php7.4-cli php7.4-common php7.4-curl php7.4-dev php7.4-fpm php7.4-enchant php7.4-gd php7.4-json php7.4-mysql php7.4-mbstring php7.4-xml php7.4-zip sudo systemctl status php7.4-fpm ``` 5. 安装redis ```shell sudo apt install redis sudo systemctl status redis ``` 6. 安装composer ```shell sudo curl -sS https://getcomposer.org/installer | php -- --version=2.6.5 sudo sudo mv composer.phar /usr/bin/composer sudo composer --version ``` 7. 安装git ```shell sudo apt install git sudo git --version ``` ### 环境配置 #### 配置php ```shell sudo vim /etc/php/7.4/fpm/pool.d/www.conf ``` 确保以下参数已正确设置: ```text listen = /run/php/php7.4-fpm.sock user = www-data group = www-data listen.owner = www-data listen.group = www-data listen.mode = 0660 ``` #### 配置nginx ```shell sudo vim /etc/nginx/nginx.conf ``` 按照如下配置修改即可 ```text user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 1024; # multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; client_max_body_size 200m; server { listen 80; server_name _; root /var/www/html; location / { index index.html index.htm index.php; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/html; fastcgi_pass unix:/run/php/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } ``` #### 重启服务 ```shell sudo systemctl restart mysql sudo systemctl restart php7.4-fpm sudo systemctl restart nginx ``` ### 系统安装 #### 拉取代码 ```shell sudo cd /var/www/html/ sudo git clone https://gitee.com/open_uhaveshop/uhs_plugin.git sudo chown -R www-data:www-data /var/www/html/uhs_plugin sudo chmod -R 755 /var/www/html/uhs_plugin/storage ``` #### 添加虚拟主机 ```shell sudo cd /etc/nginx/conf.d/ sudo vim open.uhaveshop.com.conf ``` 按照如下文件配置 ```text server { listen 80; server_name plugin.uhaveshop.com; root /var/www/html/uhs_plugin/public; index index.html index.htm index.php; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; client_max_body_size 100m; charset utf-8; # 这是laravel的规则 location / { try_files $uri $uri/ /index.php?$query_string; } # 这是laravel下博客的规则 location /article { try_files $uri $uri/ /article/index.php?$args; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ .php$ { try_files $uri =404; root /var/www/html/uhs_plugin/public; fastcgi_pass unix:/run/php/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } ``` 配置完成后校验并启用配置 ```shell sudo nginx -t sudo nginx -s reload ``` #### 开始安装 ```shell sudo cd /var/www/html/uhs_plugin/ ``` 配置数据库 ```shell # 创建uhs_plugin数据库 sudo mysql -uroot -p ... mysql> create database uhs_plugin; mysql> exit ``` 创建并编辑配置文件 ```shell sudo cp .env.example .env sudo vim .env ... DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=数据库名称 DB_USERNAME=数据库用户名 DB_PASSWORD=数据库密码 ``` 安装扩展 ```shell # composer源切换为华为云的源,否则可能安装报错 sudo composer config -g repo.packagist composer https://mirrors.huaweicloud.com/repository/php/ # 看到华为云链接即代表安装成功 sudo composer config -g -l # 安装uhs_plugin必要扩展 sudo composer install ``` ```shell # 执行数据库迁移 php artisan migrate:fresh ``` ```shell # 生成项目密钥 php artisan key:generate ``` ```shell # 执行数据库填充 php artisan db:seed ``` ```shell # 执行插件数据迁移 php artisan plugin:migrate --seed ``` ```shell # 执行插件启用/重载 php artisan plugin:reload ``` ```shell # 项目初始化 php artisan make_init ``` ```shell # 添加资源软链 php artisan storage:link ``` ### 安装certbot自动应用ssl证书 ```shell # 安装certbot sudo cd ~ sudo apt install certbot python3-certbot-nginx # 自动生成证书并配置 sudo sudo certbot --nginx -d open.uhaveshop.com # 检查证书是否生成 sudo certbot certificates # 检查证书是否配置 sudo vim /etc/nginx/conf.d/open.uhaveshop.com.conf # 打开虚拟主机配置文件后可以看到该文件中自动添加了443端口监听和ssl证书的相关配置 sudo nginx -t sudo nginx -s reload # certbot生成的证书有效期是90天,执行下面命令,可在到期时及时生成并自动配置 sudo systemctl status certbot.timer sudo certbot renew --dry-run ``` ### 其他及注意事项 相关文档 - [安装文档](https://gitee.com/open_uhaveshop/uhs_plugin). - [管理中台使用文档](https://doc.uhaveshop.vip). - [商城主题开发文档](https://doc.uhaveshop.vip). - [商城插件开发文档](https://doc.uhaveshop.vip). ## License The uhs_plugin is open-sourced software licensed under the [Apache license](https://opensource.org/licenses/Apache).