We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

18
1.024.954,85

Cart

Install X-Cart with Nginx, PHP 7.3 on Ubuntu 18.04 – Google Cloud

Install X-Cart with Nginx, PHP 7.3 on Ubuntu 18.04 – Google Cloud Platform

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

This setup is tested on Google Cloud Platform, it will also work fine on other cloud serveices and on any VPS or Dedicated servers running Ubuntu.

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

Download X-Cart

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

There is no direct download link available, so you are required to use an email address to download X-Cart to your local omputer.

Upload X-Cart Package to Google Compute Engine

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

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

Extract the X-Cart Ecommerce Software

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.

If you have downloaded a .zip file use the below command to extract.

cd /home/username/yourdomainname.com/public
unzip x-cart-5.3.6-en.tgz

If you have downloaded a .tgz file use the below command to extract.

cd /home/username/yourdomainname.com/public
tar -xzpf x-cart-5.3.6-en.tgz

Configure X-Cart package

Once you have extracted the package clean up the unwanted files and move the package files to the root directory.

sudo rm -rf x-cart-5.3.6-en.tgz
sudo mv xcart/* ~/yourdomainname.com/public
sudo rm -rf xcart

Set up correct permissions.

sudo chmod -R 755 /home/username/yourdomainname.com/public 
sudo chown -R username /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 @handler {
index cart.php;

rewrite ^/sitemap.xml(?.+)?$ /cart.php?target=sitemap;
rewrite ^/((?!images/|files/|var/theme/images/).*)$ /cart.php?url=$1 last;
}

location / {
try_files $uri $uri/ @handler;
}

location ~ .php$ {
try_files $uri @handler;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_read_timeout 3600;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
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 before the location ~ .php$ { within the server block.

location ^~ /classes {
return 403;
}

location ^~ /etc {
return 403;
}

location ^~ /files {
location ^~ /files/attachments {
try_files $uri =404;
}
location ^~ /files/vendor {
try_files $uri =404;
}
return 403;
}

location ^~ /images {
location ~* .(jpg|jpeg|gif|png|bmp|ico|tiff|flv|swf|svg|pdf) {
try_files $uri =404;
}
return 403;
}
location ^~ /Includes {
return 403;
}

location ^~ /lib {
return 403;
}

location ^~ /skins {
location ~* .(tpl|twig|php|pl|conf) {
return 403;
}
try_files $uri =404;
}

location ^~ /sql {
return 403;
}

location ^~ /var {
location ~* .(gif|jpe?g|png|bmp|css|js) {
try_files $uri =404;
}
return 403;
}

location ^~ /var/resources {
try_files $uri =404;
}

location ^~ /var/export {
return 403;
}

location ^~ /var/import {
return 403;
}

location ^~ /vendor {
return 403;
}

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 X-Cart

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

Click Click here to run the installation wizard.

Install X-Cart Step 1

Accept the license agreement and proceed to create administrator account.

While configuring the database credentials

Enter the Cloud SQL details to connect to the database.

Configuring X-Cart

For MySQL server nameenter Cloud SQL IP Address

Enter database name, username, password and proceed to next steps to complete the installation.

Wait for the installation to complete.

X-Cart homepage

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

X-Cart Admin

Conclusion

Now you have learned how to install X-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.

18
1.024.954,85

Cart