By Alexandru Andrei, Alibaba Cloud Community Blog author.
Creating your own online store is not as hard as it may first seem. It's true that it does take some time to familiarize yourself with maintaining a server, but it's worth the time and effort.
While you could pay some company to create your store on their servers, backed by their software, there is a hidden cost involved in all of this. It's often referred to as vendor lock-in. Of course, as long as you get all the features you need, this won't be an issue. But as soon as you need that something they don't support, or they so happen to not support that thing without you paying a substantial fee, you're in trouble. You have no access to the source code that powers your store and you have to agree to all the conditions they set for you. Want to double the loading time of web pages? You probably can't. Want to upgrade to HTTP/3? Only if they decide to upgrade to it. If they don't, you're stuck with the old protocol. And the examples could go on and on and on.
If you choose an open-source e-commerce platform, such as PrestaShop, Magento, or OpenCart, you get total freedom of choice over how your website works. The same is true for your server. You can install anything, optimize, and expand as you see fit. You can change anything on your website, add or remove features, implement any policy you want, use any payment processor you like. You can even sell your store to someone else, if that's what you want to do in the future. You own it 100%. And even though Alibaba rents you the computing power, storage and network resources to host your website, your store is entirely your property, and you can do anything you want with it, and on it (as long as you don't do anything illegal, or abusive, of course). And since you can pick the resources you need or prefer, and scale up and down at any time, you have control over cost, also. You don't even have to worry about being locked in to the software platform you choose. You can export your whole store from PrestaShop and import it to, say, Magento, later on, if you think that might be better suited for your business needs.
If you want to quickly spin up a PrestaShop instance, there is a marketplace image with the script pre-installed. However, it's recommended that you install all the required software yourself because this will give you more freedom to choose your own operating system and avoid pre-installed software, such as phpMyAdmin, which increases the chances of some security risks. Furthermore, the steps to configure the server itself are relatively straightforward, and you learn how everything is connected quickly. This understanding will help you fine-tune your own software components and operating system later on.
To do the things I've discussed above:
This should be able to handle websites with a moderate level of traffic with ease. It's a suggestion but not a requirement, but you can pick something better or worse, according to your needs. In the future, you can shutdown your instance and scale it up or down, depending on how it performs for your specific use case.
To determine the size of the disk, try to estimate how many product pictures you would add in a year. For example, if you estimate you would have 1,000 products added every year, each with 5 pictures, that's 5,000 pictures uploaded per year. Now, look at the average size of the images you upload. If every picture is roughly 3 megabytes in size, then that means that 15,000MB of storage space used. The database will also grow over time, and the operating system will require additional space over time as well. So, with that said, 25-30GB would be enough for your first year. However, because storage is cheap, we recommend you use a bare minimum of 40GB to start with, and more if you want to avoid future inconveniences of expanding disk size. It's important to note that the more you increase your disk capacity, the faster it will perform (you will notice IOPS increasing).
Currently, selecting extending system disk capacity requires that you turn your the ECS instance off and on again. This might change in the future. A downtime of a few minutes is acceptable for some businesses. The advantage is that the procedure is very simple. If this sort of downtime is not acceptable for your services, you can expand your storage capacity, without having to reboot your server, if you attach an additional data disk or disks to your instance and configure MariaDB and Apache to keep their files on your storage pool or pools, instead of the standard /var
path. You would have to add your data disks to a LVM or ZFS pool. The disadvantage of this method is the added complexity of setup. However, once set up correctly, it's very easy to expand in the future.
Note: The Alibaba Cloud interface is currently going through some changes, to improve user experience. This means that some elements might look or be positioned differently by the time you read this.
After you create the instance and get redirected back to the ECS console, click on Security Groups in the left-side navigation pane.
In the top-right corner, click the Create Security Group button.
Under Template, select Web Server Linux. Under Security Group Name enter web-server-firewall, so you can easily find it later. And, finally, click on VPC and select your default VPC that your instance is using. The final result should look similar to the following image.
Under these fields, you'll see the following ingress rules:
Click OK to save the security group. If you're prompted to add rules, click Close to cancel. You already have all the rules you need for your instance.
You'll land on the page that lists all security groups. Here, look for your newly created group and click on Manage Instances.
In the top-right corner you should find a button labeled Add Instance. Click on it and add your ECS instance to this group, to apply the firewall rules that will allow incoming traffic on ports 80 and 443, for your web server.
Go back to your ECS Console->Instances, so that you can find the (Internet) IP address of your server. You will need to set the proper DNS records, so that when visitors type the name of your website (such as example.com
) in their browser, they will be directed to your ECS instance.
If you don't yet have a domain name, you can register for one with Alibaba Cloud. If your domain name is currently registered at another provider, you can follow the same steps presented here, but you might need to adapt them to your registrar's control panel and the standards they follow. Add two "A records" to direct yourdomainname.com
and www.yourdomainname.com
to the public IP address of your instance.
If you have registered your domain with Alibaba Cloud, go to the DNS Console and click on your domain name or Configure.
Click on the button labeled Add Record.
After you click that button, enter these details (add an A record):
example.com
"In the following screenshot, you can see an example of how these fields can be filled in.
Now, repeat the same steps, enter the same values, except, in the Host field, enter www instead of @. This will direct www.yourdomainname.com
to the server's IP address, so that visitors can access your website with both yourdomainname.com
and www.yourdomainname.com
.
If you already had different A records configured for your domain name, the changes will take some time until they propagate.
Use a DNS propagation check tool like DNS checker, or search the web for "dns propagation check" if this website is down in the future. Check both "yourdomainname.com" and "www.yourdomainname.com". If all results point to your current instance's IP address, and not the old one, you're good to go. Don't worry about "Not resolved" errors, marked with an "x" sign. That doesn't mean there's something wrong on your side, just that the DNS resolver in that location is currently down for some reason.
Do not continue with this tutorial until DNS changes have propagated properly! Otherwise, you won't be able to set up SSL/TLS certificates, to enable HTTPS for your site, until the DNS records propagate to the servers that will check domain ownership.
First, use an SSH client to log in to your instance, as the root user. Upgrade all packages on your Debian operating system.
apt update && apt upgrade
You may get a prompt about configuration files, similar to this one:
You can press ENTER to select the default entry, "keep the local version currently installed." Alibaba changes some configuration files to optimize ECS functionality and it's usually better to preserve these modifications.
Reboot your instance.
systemctl reboot
Wait around 30 seconds and then log back in as the root user.
Install the web server and database server, along with some requirements to process PHP files and some PHP plugins required by PrestaShop.
apt install apache2 mariadb-server php-fpm php-mysql php-curl php-gd php-zip php-xml php-intl
Tighten the following MariaDB settings to slightly increase overall security.
mysql_secure_installation
Enter current password for root (enter for none):
Press ENTER here.
Set root password? [Y/n]
Type n
and press ENTER. Password logins, as root, to the database server, are disabled by default anyway in recent versions of MariaDB.
Type Y
, followed by ENTER to the rest of the questions.
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
Create a new website configuration file.
nano /etc/apache2/sites-available/prestashop.conf
Paste this text, but remember to replace yourdomainname.com
with your real domain name in both places where this string appears.
<VirtualHost *:80>
ServerName yourdomainname.com
ServerAlias www.yourdomainname.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/>
AllowOverride All
</Directory>
</VirtualHost>
Save the file, by pressing CTRL+x, followed by y and, finally, ENTER.
Disable the default website configuration.
a2dissite 000-default.conf
Enable the new configuration you created.
a2ensite prestashop.conf
Apache MPM event should be enabled by default. But just to make sure, enter this command.
a2enmod mpm_event
Enable FastCGI module.
a2enmod proxy_fcgi setenvif
The next command (a2enconf php7.0-fpm
) applies to Debian 9. If you're using Debian 10 or above, type a2enconf php
and press TAB to autocomplete the correct value (e.g., in Debian 10 this might autocomplete to a2enconf php7.3-fpm
).
Enable the PHP-FPM processor.
a2enconf php7.0-fpm
Restart Apache to apply changes.
systemctl restart apache2
Install Certbot.
apt install python-certbot-apache
Start the TLS certificate request. Replace yourdomainname.com
with your real domain name, in both places.
certbot --apache -d yourdomainname.com -d www.yourdomainname.com
Follow the steps displayed in your SSH session. When prompted, enter your current personal email address. You can use this to manage certificate operations in the future. When prompted, press a
to agree to the terms and conditions, otherwise the script will abort.
At this prompt:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
Press 1
and then ENTER. If you enable redirects at this point, you might get some redirect loops later on in PrestaShop, which will prevent normal operation. You will enable HTTPS redirections later on, from PrestaShop's administrative interface.
Remove default webpage.
rm /var/www/html/index.html
Change to the directory where you will store your web server files.
cd /var/www/html
Install wget and unzip to download and extract PrestaShop's files.
apt install wget unzip
Open your preferred web browser, and visit PrestaShop's download page. Start the download and then go into your browser's download list to find the URL that points to the archive. For example, in Chrome you can press CTRL+J and you would see the following:
Copy the download link and use it in the next command. With the example in the picture, the command would be:
wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
By the time you read this though, a new version will be released, so remember to replace https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
with the URL pointing to the newest PrestaShop release.
Extract the files from the downloaded archive.
unzip *.zip
The web server runs under the www-data
user, but this user doesn't have any write permissions in /var/www/html
, where PrestaShop files are stored. This means the install script can't run and PrestaShop can't be updated through the administrator interface, plugins can't be installed/upgraded automatically, and so on. To solve this, make the www-data
user, owner of the directory /var/www/html
and files stored within.
chown -R www-data: /var/www/html/
Open your browser again and enter your domain name, but precede it with https! It's very important to enter your domain name in a form like https://yourdomainname.com
. If you write yourdomainname.com
, you will connect through a regular HTTP connection. When you enter some passwords, these will be transmitted over the network, unencrypted, which is a potential security issue.
PrestaShop installer script will run, extract files, and then present you with this page:
Follow the easy steps in the install wizard.
Important: When you are asked for an email address, choose the one that you will configure as your public email for your store. For example, if you want your store to send emails from
shop@yourdomainname.com
, then choose this as the username/email address in the install wizard. If you don't do this, later on when you will configure a sending email address for PrestaShop, your email will either not be sent, or marked as spam. If you fill in the wrong email address, or need to change it later on, in the administrative backend, go to "Shop Parameters->Contact" and then click on "Stores" tab, and finally, look for the "Shop email" field. Here, enter the same email that you will use in PrestaShop's SMTP settings.
When you reach the point where you have to configure your database server credentials, pause, and return to the SSH session to create required database and user.
Connect to MariaDB server:
mariadb
The command prompt will display MariaDB [(none)]>
. This indicates that you are now entering commands to the MariaDB server.
In the next three commands, you will have to change the example values, to real values you want to choose for your database. The strings you need to modify are highlighted in the next picture.
Choose a database name:
CREATE DATABASE database_name ;
Choose a username and password with which PrestaShop will login to this database, to get the privilege to use and modify it.
CREATE USER user_name@localhost IDENTIFIED BY 'password' ;
Grant your chosen username, all permissions over the database you created.
GRANT ALL PRIVILEGES ON database_name.* TO user_name@localhost ;
Exit from MariaDB's command line interface.
exit
Return to your browser and fill in the database connection details, with the database name, username and password you chose earlier. Leave Database server address and Tables prefix unmodified (with their default values).
Test your database connection details (click the corresponding button on the web page).
In the next step, PrestaShop will configure the database. After it's done, you will be presented with a page like this (don't click on anything yet):
Leave it open and return to your SSH session to enter this command:
rm -r install/
Now return to your web browser and click on Back Office. Bookmark this URL in your browser, so that you can easily return to the administrative backend in the future. The URL will contain a string that is hard to remember, something like admin417d2bkou
. If you ever lose access to this URL, you can type this command in an SSH session to remember the required address:
ls -d /var/www/html/adm*
If you get an entry like admin417d2bkou
, just enter https://yourdomainname.com/admin417d2bkou
in your browser to return to PrestaShop's administrative interface.
Log in with your administrator username (e-mail) and password, that you chose in the install wizard, and look for Shop Parameters in the left-side menu. This might be hidden under this tutorial progress bar:
Click "Resume" or "Stop the OnBoarding" to reveal the menu entry of interest.
Under "Shop Parameters," click on General in the submenu. Here, click on Please click here to check if your shop supports HTTPS. You might encounter a warning and you should select the option labeled as "I understand the risks" to continue. Now, Enable SSL on all pages by clicking on YES and then scroll down to save the settings. All page requests will now be redirected to use the encrypted HTTPS protocol.
An online web store has to do a lot of things through email. New user accounts are confirmed through email, password resets are done through the same medium, clients get order confirmations, shipment statuses, and so on. So it is important that you choose a reputable service for sending emails. Otherwise, the odds of emails hitting the Spam folder increases, and that's not good for business. Do not use your personal email account! It has a low limit on number of emails that can be sent daily, weekly and monthly.
In the left-side menu, under Advanced Parameters, you will find E-mail in the submenu. Here, click on Set my own SMTP parameters (for advanced users ONLY) and then save your settings.
Now, if you scroll down, you will see these fields:
You will have to fill these, according to your email provider's instructions. The only thing disallowed is the use of port 25. This is blocked by Alibaba for security purposes. But most providers, use secure ports such as 465 or others, anyway, so it shouldn't be an issue.
Alibaba Cloud offers its own email service, if you want to use it. Instructions on how to do so will be offered below.
Follow these steps to setup DirectMail for your domain name, keeping these suggestions in mind:
1. If your website visitors don't come from Asia, change your DirectMail location to Australia or whatever continent is closest to you (and available).
2. When you get to the "Sender Addresses" section, look carefully for the SMTP server address displayed in the bottom of the page. If you use the servers in Singapore, it might look similar to this:
3. Configure a "Reply-To Address," so that you can receive the occasional mail on your sending address. You can enter your personal address in this section. Whenever you get an email to your store's email address, it gets redirected to your personal email.
After you configured your email sender address with Alibaba (or another business email provider), return to PrestaShop's administrative interface, go to Advanced Parameters > E-mail and enter these details:
www
string (e.g., yourdomainname.com
)smtpdm-ap-southeast-1.aliyun.com
your_email@yourdomainname.com
(true for Alibaba DirectMail too). But some email providers may use other forms, so read their instructions if this doesn't work.Periodically upgrade your server with apt update && apt upgrade
, and then reboot to keep up with security upgrades. Also upgrade PrestaShop through the administrative back-end.
To backup everything easily, you can use snapshots (if you don't use LVM or ZFS). You can set up automatic, periodic snapshots. If you do so, it's recommended you schedule them at a time when your website is least visited (like 4AM, local time), so that you don't impact disk performance and make your website load slowly for visitors.
You can learn more about PrestaShop or visit their forum and ask a question when you run into trouble.
Create Your Own Dedicated Server for Playing Counter Strike: Global Offensive (CS:GO)
2,599 posts | 762 followers
FollowAlibaba Clouder - July 2, 2019
Alibaba Clouder - August 22, 2018
Alibaba Clouder - August 22, 2018
Alibaba Clouder - June 13, 2019
Alibaba Clouder - April 16, 2019
Alibaba Cloud Community - December 12, 2023
2,599 posts | 762 followers
FollowElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAn encrypted and secure cloud storage service which stores, processes and accesses massive amounts of data from anywhere in the world
Learn MoreLearn More
More Posts by Alibaba Clouder