Compute Engine Google Cloud

Install CS-Cart with LEMP on Ubuntu 18.04 – Google Cloud

Install CS-Cart with LEMP on Ubuntu 18.04 – Google Cloud.

This guide, explains the steps to install CS-Cart with LEMP on Ubuntu 18.04.

This setup is tested on Google Cloud Platform, so this guide can be used on any other cloud hosting services or VPS or Dedicated server running Ubuntu.

Choose Best Hosting for your Business

PlatformReviewsPricing
Siteground★★★★★$3.95
Bluehost★★★★★$3.95
Kinsta – Google Cloud★★★★★$30

Prerequisites

With the above-completed prerequisites I assume you have your Nginx, PHP installed and Cloud SQL is configured.

Set up your Website Directory

Your website will be located in the home directory and have the following structure

Replace yourdomainname.com with your original domain name.

home
-- yourdomainname.com
---- logs
---- public

The public directory is your website’s root directory and logs directory for your error logs

Now we create these directories and set correct permissions

You need to SSH into your VM Instance and run these commands

mkdir -p yourdomainname.com/logs yourdomainname.com/public
sudo chmod -R 755 yourdomainname.com

Download CS-Cart

Once you have your Ubuntu server set up in Google Compute Engine, you can download CS-Cart from their official website.

There is no direct download link available, so you are required to use an email address to receive a download link.

Upload CS-Cart Package to Google Compute Engine

Now you can upload the downloaded CS-Cart zip file to your VM Instance by once of the following methods.

Upload the file to this directory /home/username/yourdomainname.com/public

Extract the CS-Cart Zip

Once you have uploaded the zip file you can proceed to extract the file. So move to the uploaded folder and extract it. Replace the version number with the one you have downloaded.

cd /home/username/yourdomainname.com/public
sudo unzip cscart_v4.9.3.sp1.zip -d /home/username/yourdomainname.com/public

Set up correct permissions.

sudo chown -R username /home/username/yourdomainname.com/public
sudo chmod -R 755 /home/username/yourdomainname.com/public

Configure Nginx

Create a new Nginx configuration for your website in the sites-available directory.

 sudo nano /etc/nginx/sites-available/yourdomainname.com

Copy and paste the following configuration, ensure that you change the server_name, error_log and root directives to match your domain name. Hit CTRL+X followed by Y to save the changes.

 server {
listen 80;
listen [::]:80;
server_name yourdomainname.com www.yourdomainname.com;

error_log /home/username/yourdomainname.com/logs/error.log;

root /home/username/yourdomainname.com/public/;
index index.html index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ ^/(\w+/)?(\w+/)?api/ {
rewrite ^/(\w+/)?(\w+/)?api/(.*)$ /api.php?_d=$3&ajax_custom=1&$args last;
rewrite_log off;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

Hit Ctrl+X followed by Y and Enter to save the file and exit.

To enable this newly created website configuration, symlink the file that you just created into the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/yourdomainname.com /etc/nginx/sites-enabled/yourdomainname.com

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Advanced Nginx Configuration

You can use these advanced configuration below the location ~ .php$ { within the server block.

location ~ ^/(\w+/)?(\w+/)?var/database/ {
return 404;
}
location ~ ^/(\w+/)?(\w+/)?var/backups/ {
return 404;
}
location ~ ^/(\w+/)?(\w+/)?var/restore/ {
return 404;
}
location ~ ^/(\w+/)?(\w+/)?var/themes_repository/ {
allow all;
location ~* .(tpl|php.?)$ {
return 404;
}
}
location ~ ^/(\w+/)?(\w+/)?var/ {
return 404;
location ~* /(\w+/)?(\w+/)?(.+.(js|css|png|jpe?g|gz|yml|xml))$ {
try_files $uri $uri/ /$2$3 /$3 /index.php?$args;
allow all;
access_log off;
expires 1M;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
}
location ~ ^/(\w+/)?(\w+/)?app/payments/ {
return 404;
location ~ .php$ {
return 598;
}
}
location ~ ^/(\w+/)?(\w+/)?app/addons/rus_exim_1c/ {
return 404;
location ~ .php$ {
return 598;
}
}
location ~ ^/(\w+/)?(\w+/)?app/ {
return 404;
}
location ~* /(\w+/)?(\w+/)?(.+.(jpe?g|jpg|ico|gif|png|css|js|pdf|txt|tar|woff|svg|ttf|eot|csv|zip|xml|yml))$ {
access_log off;
try_files $uri $uri/ /$2$3 /$3 /index.php?$args;
expires max;
add_header Access-Control-Allow-Origin *;
add_header Cache-Control public;
}
location ~ ^/(\w+/)?(\w+/)?design/ {
allow all;
location ~* .(tpl|php.?)$ {
return 404;
}
}
location ~ ^/(\w+/)?(\w+/)?images/ {
allow all;
location ~* .(php.?)$ {
return 404;
}
}
location ~ ^/(\w+/)?(\w+/)?js/ {
allow all;
location ~* .(php.?)$ {
return 404;
}
}
location ~ ^/(\w+/)?(\w+/)?init.php {
return 404;
}
location ~* .(tpl.?)$ {
return 404;
}
location ~ /.(ht|git) {
return 404;
}
location ~* .php$ {
return 598 ;
}

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Install CS-Cart

Now visit your domain name in the web browser, you will see the installation page of CS-Cart.

Install Cs-Cart

Enter the Cloud SQL details and follow the instructions carefully and click Install.

For MySQL server host enter Cloud SQL IP Address

Wait for the installation to complete.

Then you can login with the credentials you have created with the installation wizard.

Conclusion

Now you have learned how to install CS-Cart on your Ubuntu server with Nginx in Google Cloud.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cloudbooklet builds a large collection of Linux based guides and tutorials on Cloud platforms like Google Cloud, AWS, Azure, DigitalOcean and more

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.