Location>code7788 >text

Open source PHP mall project CRMEB secondary development and deployment tutorials

Popularity:179 ℃/2024-11-11 12:26:19

The previous article gave you an overview of theHow to Deploy CRMEB Open Source Mall System with Sealos App Store in One Click, that's really fast, much faster than the Pagoda!

But some readers weren't satisfied with that and asked meCan you change the code while running, and you have to use Cursor to change the code, and the online environment has to take effect in real time after the change.

All I can say to that is, you've got your eye on the Cursor's bullseye and you want it to automatically change your code for you, don't you? Is it like this?

You think that's going to be hard for me?

Hey, hey, that's really something.

Without further ado, let's get right to the tutorial!

Creating a Devbox Development Environment

first enterSealos DesktopDevbox supports many major languages and frameworks, here we need to deploy the CRMEB mall system, so we directly choose PHP as the runtime environment.

Choose PHP version 7.4, CPU memory 1C2G is enough, you can always add more if it's not enough. Change the port to 80, because CRMEB is exposed to Nginx, the system will automatically assign a HTTPS domain name, through which you can access port 80 in Devbox.

Click Create to start the development environment in a few seconds.

Next, click on Cursor in the Action Options, which will automatically open the local Cursor Programming IDE.

You will then be prompted to install the Devbox plugin, which will automatically connect you to your development environment.

Isn't it very simple?Directly omit the configuration of domain name resolution, apply for SSL certificates, configure the gateway and other non-development-related tedious operation, cool!

Deployment of CRMEB

1. Cloning of warehouses

Open Cursor's terminal and execute the following command to clone the CRMEB project into the Devbox development environment:

git clone //crmeb/CRMEB
mv CRMEB/{*,.*} .
rm -rf CRMEB

2. Install and configure php-fpm

Install some dependencies:

sudo apt-get update
sudo apt-get -y --no-install-recommends install php7.4-fpm php7.4-curl php7.4-bcmath php7.4-redis php7.4-mysqli php7.4-gd

Create a new php-fpm configuration file:

sudo touch /etc/php/7.4/fpm//

Then write the following to the configuration file

upload_max_filesize = 100M
post_max_size = 108M
open_basedir = "/home/devbox/project/crmeb:/var:/var/tmp/:/tmp/"
disable_functions = system, exec, shell_exec, passthru, proc_get_status, checkdnsrr, getmxrr, getservbyname, getservbyport, syslog, popen, show_source, highlight_file, dl, socket_listen, socket_create, socket_bind, socket_accept, socket_connect, stream_socket_server, stream_socket_accept, stream_socket_client, ftp_connect, ftp_login, ftp_pasv, ftp_get, sys_getloadavg, disk_total_space, disk_free_space, posix_ctermid, posix_get_last_error, posix_getcwd, posix_getegid, posix_geteuid, posix_getgid, posix_getgrgid, posix_getgrnam, posix_getgroups, posix_getlogin, posix_getpgid, posix_getpgrp, posix_getpid, posix_getppid, posix_getpwnam, posix_getpwuid, posix_getrlimit, posix_getsid, posix_getuid, posix_isatty, posix_kill, posix_mkfifo, posix_setegid, posix_seteuid, posix_setgid, posix_setpgid, posix_setsid, posix_setuid, posix_strerror, posix_times, posix_ttyname, posix_uname
upload_tmp_dir = /var/www/temp

Modify the way php-fpm listens so that it listens locally on port 9000:

sudo sed -i 's|listen = .*|listen = 127.0.0.1:9000|' /etc/php/7.4/fpm//

Softlink the crmeb directory to the /var/www directory:

sudo rm -rf /var/www
sudo ln -s ${PWD}/crmeb /var/www

Modify directory permissions:

cd /home/devbox/project/crmeb
sudo mkdir backup & sudo chmod a+w backup
sudo chmod a+w public
sudo chmod a+w runtime
sudo chmod a+w .env
sudo chmod a+w .version
sudo chmod a+w .constant

3. Install and configure Nginx

Install Nginx:

sudo apt-get -y --no-install-recommends install nginx
sudo rm -rf /etc/nginx/sites-enabled

Create an Nginx configuration file:

sudo touch /etc/nginx//

Then write the following to the configuration file

server {
    listen 80;
    index  ;
    server_name _;

    root /var/www/public;


    location / {
        # try_files $uri /$is_args$args;
        if (!-e $request_filename){
            rewrite  ^(.*)$  /?s=$1  last;   break;
        }
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
        error_log off;
        access_log /dev/null;
    }
    
    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log /dev/null; 
    }
    location /notice {
        proxy_pass http://127.0.0.1:20002;  
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
    location /msg {
        proxy_pass http://127.0.0.1:20003/;  
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
    
   

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index ;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
    
   
}

4. Activation of CRMEB

Write the following command to

#!/bin/bash
sudo /etc//php7.4-fpm start
sudo /etc//nginx start
php7.4 think timer start --d
php7.4 think workerman start --d 

Great job, now we can pass the The script officially starts the CRMEB:

./

Now go back to the Devbox interface and go to the crmeb development environment details page:

Clicking on the extranet address opens the CRMEB web interface.

Let's not rush the installation, we still need to install MySQL and Redis, and then we'll come back to the installation.

Installation of the database

Installation in Sealoscomprehensive databaseIt's very simple, just have a hand. Just click on [Database]:

Then click [New Database], select MySQL, give it a name, and then click [Deploy] in the upper right corner.

After deployment, you still need to go into the MySQL terminal to create a database, directly from the MySQL details page click [Connect] to enter the terminal:

Then execute the following SQL statement to create a file namedcrmeb of the database.

CREATE DATABASE IF NOT EXISTS crmeb;

Just close the terminal when you are done creating it.

Similarly, another Redis database has to be deployed.

Now that the database is deployed, let's go back to the CRMEB installation screen and continue the installation.

Installation CRMEB Mall

Start installing the mall system!

The next step requires you to enter the database connection information, other parameters remain unchanged by default, you only need to fill in the values of [database password] and [database server].

The values of [Database Password] and [Database Server] are obtained as follows:

Open [App Store], click [My Apps] in the lower left corner, enter your CRMEB app, and then click [Details] of MySQL database to enter the details page of MySQL database.

Click on the little eye on the left to see the password and address of the MySQL database.

Go back to the CRMEB installation interface, fill in the MySQL connection information, continue to the next, set the administrator password, select Redis as the caching method, and keep the other values unchanged, enter the values of [Server Address] and [Database Password], and get them in a similar way as MySQL, and then find the connection information of the Redis database in Sealos.

Once all the information is filled in, click [Next] to start the installation.

Installation was successful! Go to the backend:

After logging into the background, click [Settings] in the lower left corner, set the website name and website address, and then click Submit.

It's also possible to turn on message queuing - we're hooked up to Redis, after all.

After refreshing the page, all the content of the site will be displayed correctly.

Let's see what the front end looks like again:

The specific configuration of the mall system can be found inOfficial CRMEB DocumentationThe article is not going to go into the details.

summarize

Compared with one-click deployment in Sealos App Store, deploying in Devbox development environment is more convenient for us to modify the source code at any time, and we can directly connect to the development environment through Cursor and use AI to help us modify the source code.

If you want to do secondary development based on this project, then this deployment is perfect.

The tradeoff, of course, is that the deployment step is a bit more complicated and requires a bit of command line knocking.

If you only want to deploy the project quickly and have no development needs, then use theSealos App StoreDeployment is the fastest way.