fecshop 官网使用的 centos 配置有点和 ubuntu 不一样, 当然你也可以使用 docker 来搞 不过看了源码 , 域名有点怪怪的, 当然你可以用 nginx 代理在代理..
话不多说了, 如果你想要一个比较成熟的 B2C 电商的话, 你可以试试这个
- https://github.com/fecshop/yii2_fecshop
- # 如果你要用 php 最新版本的话目前为 7.2
- sudo apt-get install python-software-properties software-properties-common
- sudo add-apt-repository ppa:ondrej/php
- sudo apt-get update
服务器配置
sudo apt install nginx php php-sqlite3 php-mysql php-xml php-curl php-gd php-mbstring php-cli git unzip redis-server php-redis mysql-server mongodb php-mongo php-mongodb php-soap php-imap php-oauth
主意使用的 composer 必须为 >= 1.3 所以不要使用 apt install composer
- 请使用这种方法安装
- php -r "copy('https://getcomposer.org/installer','composer-setup.php');"
- php -r "if (hash_file('SHA384','composer-setup.php') ==='544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo'Installer verified'; } else { echo'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- sudo mv composer.phar /usr/local/bin/composer
- xunSearch
- apt-get install make gcc g++
- apt-get install zlib1g-dev
- wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2
- tar -xjf xunsearch-full-latest.tar.bz2
- cd xunsearch-full-1.3.0/
- sh setup.sh
- fecshop
- composer global require "fxp/composer-asset-plugin:^1.3.1"
- composer create-project fancyecommerce/fecshop-app-advanced fecshop 1.4.5.0
- # 重要的一步
- cd fecshop
- composer update
- ./init
如果使用的是 composer 安装的 fecshop 记得 vim /etc/hosts 中添加
127.0.0.1 xunsearch
因为源码中
- 使用的 xunsearch
- fsockopen('xunsearch', 8383, 0, 'php_network_get...', 5)
nginx 配置
- vim /etc/nginx/nginx.conf
- 在 http 模块中添加
- http{
- ...
- include /mnt/hgfs/fecshopVM/nginx/*; // 虚拟机的路径
- }
我这里使用的是监听 9000 端口
- vim /etc/php/7.2/fpm/pool.d/www.conf
- 修改
- listen 127.0.0.1:9000
在 Ubuntu 目录下新建 nginx 文件夹下 新建两个文件
- fcgi.conf ,none.conf
- fcgi.conf
- # nginx conf conf/fcgi.conf
- # Created by http://www.wdlinux.cn
- # Last Updated 2010.06.01
- if ($request_filename ~* (.*)\.php) {
- set $php_url $1;
- }
- if (!-e $php_url.php) {
- #return 403;
- }
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx;
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name;
- fastcgi_param REQUEST_URI $request_uri;
- fastcgi_param DOCUMENT_URI $document_uri;
- fastcgi_param DOCUMENT_ROOT $document_root;
- fastcgi_param SERVER_PROTOCOL $server_protocol;
- fastcgi_param REMOTE_ADDR $remote_addr;
- fastcgi_param REMOTE_PORT $remote_port;
- fastcgi_param SERVER_ADDR $server_addr;
- fastcgi_param SERVER_PORT $server_port;
- fastcgi_param SERVER_NAME $server_name;
- # PHP only, required if PHP was built with --enable-force-cgi-redirect
- fastcgi_param REDIRECT_STATUS 200;
- none.conf
- location / {
- index index.html index.php; ## Allow a static html file to be shown first
- try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
- expires 30d; ## Assume all files are cachable
- }
- location /. { ## Disable .htaccess and other hidden files
- return 404;
- }
- location @handler { ## Magento uses a common front handler
- rewrite //index.php;
- }
- location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
- rewrite ^(.*.php)/ $1 last;
- }
- # Appadmin
- # /mnt/hgfs/fecshopVM/www
- server {
- listen 80 ;
- server_name appadmin.fecshop.com;
- root /mnt/hgfs/fecshopVM/www/fecshop/appadmin/web;
- server_tokens off;
- include none.conf;
- index index.php index.html index.htm;
- access_log /www/web_logs/access.log wwwlogs;
- error_log /www/web_logs/error.log notice;
- location ~ \.php$ {
- fastcgi_pass php:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
- expires 30d;
- }
- location ~ .*\.(js|CSS)?$ {
- expires 12h;
- }
- }
- 记得 上传图片一定要 配置 一个静态服务器 路由
- # img
- server {
- listen 80 ;
- server_name img.fecshop.com;
- root /www/web/fecshop/appimage/common;
- server_tokens off;
- include none.conf;
- index index.php index.html index.htm;
- access_log /www/web_logs/access.log wwwlogs;
- error_log /www/web_logs/error.log notice;
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
- expires 30d;
- }
- }
还有配置 Image.php 配置文件
- cd @fecshop/common/config/fecshop_local_services/Image.php
- 'common' => [
- 'basedir' => '@appimage/common',
- 'basedomain' => '//img.fecshop.com',
- ],
- basedomain 修改为自己的静态路由文件
前台配置
- cd @fecshop/appfront/config/fecshop_local_services/Store.php
- 修改 stores 中的 域名为自己的 网站域名
- nginx 配置如下
- # AppFront
- server {
- listen 80 ;
- server_name appfront.fecshop.com appfront.fecshop.es;
- root /mnt/hgfs/fecshopVM/www/fecshop/appfront/web;
- server_tokens off;
- include none.conf;
- index index.php index.html index.htm;
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location ~ /sitemap.xml
- {
- if ($host ~ .*appfront.fecshop.es) {
- rewrite ^/sitemap\.xml /sitemap_es.xml last;
- }
- }
- location /fr/ {
- index index.php;
- if (!-e $request_filename){
- rewrite . /fr/index.php last;
- }
- }
- location /es/ {
- index index.php;
- if (!-e $request_filename){
- rewrite . /es/index.php last;
- }
- }
- location /cn/ {
- index index.php;
- if (!-e $request_filename){
- rewrite . /cn/index.php last;
- }
- }
- location /de/ {
- index index.php;
- if (!-e $request_filename){
- rewrite . /de/index.php last;
- }
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
- expires 30d;
- }
- location ~ .*\.(js|css)?$ {
- expires 12h;
- }
- }
然后到
- 编辑配置文件
- vim @fecshop/common/config/main-load.php
- 然后回到 fecshop 根目录
- cd fecshop 执行 yii 的数据 迁移文件
- Mysql
- ./yii migrate --interactive=0 --migrationPath=@fecshop/migrations/mysqldb
- MongoDB
- ./yii mongodb-migrate --interactive=0 --migrationPath=@fecshop/migrations/mongodb
- 默认密码 后台密码
- admin admin123
如果使用的是 php 7.2 请讲 yii2 升级到 >=2.0.13
要不会报错 Object
php 7.2 把 Object 设为关键词
如果还不行的话,
"hightman/xunsearch": "dev-master"
这个包请升级
- composer.json
- "yiisoft/yii2": ">=2.0.13",
- "hightman/xunsearch": "dev-master",
来源: https://juejin.im/entry/5b309f8cf265da595d2ec5ef