How to Install and Configure Paste


  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  3. Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  4. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  5. Set up your server’s hostname and create user with root privileges.

Setting Up Your Server

Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges.

# sudo apt update && sudo apt upgrade
# sudo apt-get install unzip -y

Install PHP

Paste requires installation of PHP 5.6 or newer version of PHP. In this tutorial, you will install PHP 7.2. To install PHP 7.2, execute the following steps.

# sudo apt-get install software-properties-common python-software-properties
# sudo add-apt-repository ppa:ondrej/php
# sudo apt update
# sudo apt install -y php7.2
  1. php7.2-imagick
  2. php7.2-common
  3. php7.2-mbstring
  4. php7.2-gd
  5. php7.2-xml
  6. php7.2-mysql
  7. php7.2-curl
  8. php7.2-zip
  9. php7.2-tidy
  10. libapache2-mod-php
# sudo apt-get -y install php-gd php-mbstring php-common php-mysql php-imagick php-xml libapache2-mod-php php-curl php-tidy php-zip
# php --version

Install MariaDB

Paste supports MySQL. In this tutorial, you will use MariaDB server. By default, Ubuntu repository has older version of MariaDB server. To use new version of MariaDB, you will need to add MariaDB repository to your Ubuntu system. To do so, follow the steps below.

# sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
# sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] xenial main'
# sudo apt update
# sudo apt install -y mariadb-server
# sudo systemctl start mariadb
# sudo systemctl enable mariadb
# sudo mysql_secure_installation
# sudo mysql -u root -p
CREATE DATABASE pastedb CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'aareez'@'localhost' IDENTIFIED BY '654321Ab';
GRANT ALL PRIVILEGES ON pastedb.* TO 'aareez'@'localhost';

Install Paste

To install Paste, you will need to follow the steps.

# cd /var/www
# sudo wget --content-disposition
# sudo unzip
# sudo rm
# sudo chown -R www-data:www-data /var/www

Configure Apache Server

Let’s create virtual host configuration file for Paste. Execute the following command, a file will be opened in nano text editor.

# sudo nano /etc/apache2/sites-available/paste.conf
<VirtualHost *:80> 
DocumentRoot /var/www/
DirectoryIndex index.php index.htm index.html
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
ErrorLog ${APACHE_LOG_DIR}/Paste_error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/Paste_access.log combined
# sudo a2dissite 000-default.conf
# sudo a2ensite paste
# sudo a2enmod rewrite
# sudo a2enmod ssl
# sudo service apache2 restart
# sudo rm -r /var/www/install

Install SSL Certificate

To install SSL certificate using let’s encrypt, you will use Certbot. To do so, execute the following steps.

# sudo apt-get update
# sudo apt-get install software-properties-common
# sudo add-apt-repository ppa:certbot/certbot
# sudo apt-get update
# sudo systemctl stop apache2
# sudo apt-get install python-certbot-apache
# sudo certbot --apache -d
# sudo systemctl start apache2

Set Up Firewalls for Required Ports

If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add exception for port 80/tcp and 443/tcp. You can enable these ports while creating ECS instance, but in case, if you have forgotten to unblock these ports, you can follow the procedure below. By default, these ports are blocked by the firewalls.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud


Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: