Installing PHP7.0 MongoDB extension Ubuntu 16.04

The new PHP 7.0 is twice as fast as compared to previous ones, we are going to setup new MongoDB extension for PHP.

Installing PHP MongoDB extension

I am assuming that you have already installed php7.0 and now wants to install MongoDB PHP7.0 extension

We will need the following PHP 7.0 libraries :

sudo apt-get -y install php7.0-fpm php7.0-cli php7.0-json php7.0-curl php7.0-gd php7.0-mysqlnd php7.0-imap php7.0-mcrypt php7.0-mbstring php7.0-xml php7.0-zip php7.0-intl php7.0-dev

Installing required libraries for MongoDB

We also need OpenSSL libraries to be installed to be used in creating MongoDB secure connections

sudo apt-get install libcurl4-openssl-dev pkg-config libssl-dev libsslcommon2-dev

pecl install mongodb

Configuring php.ini

We need to add the line "extension=mongodb.so" to php.ini configuration file at the end, based on your configuration you can find the file location

sudo nano /etc/php/7.0/fpm/php.ini

You can now save the file and restart PHP and Nginx to enable the changes.

sudo service php7.0-fpm restart
sudo service nginx restart

Easy LEMP Stack on Ubuntu 16.04

Ubuntu 16.04 is the new stable version of Ubuntu and has many security fixes to get a website up and running much faster we will use Nginx, MariaDB, PHP7.0-FPM they together are called LEMP stack.

STEP 1: Installing Nginx

To Display web pages to visitors we need to install Nginx to do so we will use an apt command in Linux.

sudo apt-get update
sudo apt-get install nginx

 

After installation, Nginx has started automatically.

step2: Configuring Firewall

If you have the ufw firewall running, as outlined in our initial setup guide, you will need to allow connections to Nginx. Nginx registers itself with ufw upon installation, so the procedure is rather straightforward.

sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'OpenSSH'
sudo ufw enable

sudo ufw status

 

Type one of the addresses that you receive in your web browser. It should take you to Nginx’s default landing page:

http://server_domain_or_IP

Step3: Installing MariaDB

I am using MariaDB instead of MySQL because I like MariaDB for its better performance, if you want MySQL you can install it, there will be no problem.

Run the following commands to install MariaDB

sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu xenial main'

Once the key is imported and the repository added you can install MariaDB with:

sudo apt update
sudo apt install mariadb-server

Step4: Installing PHP for Processing

We now have Nginx installed to serve our pages and MariaDB installed to store and manage our data. However, we still don’t have anything that can generate dynamic content. We can use PHP with Fast processing for this.

Since Nginx does not contain native PHP processing like some other web servers, we will need to install PHP-fpm, which stands for “fastCGI process manager”. We will tell Nginx to pass PHP requests to this software for processing.

sudo apt-get install php-fpm php-mysql

Step4: Configure Nginx to Use the PHP Processor

Now we have everything ready, The only configuration change we still need is to tell Nginx to use our PHP processor for dynamic content.

We do this on the server block level (server blocks are similar to Apache’s virtual hosts). Open the default Nginx server block configuration file by typing:

sudo nano /etc/nginx/sites-available/default

server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}

You can test the working by creating a sample file and you are done. For any issue feel free to drop any comments.

Thanks

Configure FTP Backup VestaCP Ubuntu

VestaCP is the best Open-Source Control Panel for Web Admins which has the option to FTP Backup all your files to a different server. Follow this tutorial to configure FTP backup on Ubuntu Server.

We are assuming that you have successfully setup High-Security Firewall for the Server and port 21 is open on both servers.

Login to server

I have bought 4GB Dedicated Server with 500GB SATA to use that as FTP Backup server for all my client files, now I will log into my server through ssh, Replace with your own server user and ip

ssh [email protected]

FTP Backup Command

VestaCP provides us with sets of useful commands one of the command is for setting up FTP backup server

Format
/usr/local/vesta/bin/v-add-backup-host TYPE HOST USERNAME PASSWORD [PATH] [PORT]

Example
/usr/local/vesta/bin/v-add-backup-host ftp example.com admin pa$$word /home/user 21
Replace with your own FTP server details.

 

Verify FTP Server Added

After you have set the FTP backup server through command line you need to verify that it is successfully added to the system, to verify that run the command below and match the details, if nothing shows up you are either on newer version of VestCP, comment below for any issue

nano /usr/local/vesta/conf/ftp.backup.conf

Backup Files

You need to change the configuration of VestaCP to make FTP as your default backup, edit the file

nano /usr/local/vesta/conf/vesta.conf

 

search for BACKUP_SYSTEM and set its value to ftp. Now you can easily take backup of all your files and configure the CRON job from VestaCP CRON dashboard. Run the following command to take FTP Backup of your Server.

/usr/local/vesta/bin/v-backup-users

 

Now you can check the backup server with the path we specified.