Install Pagekit on a Debian 7 VPS with Nginx, PHP-FPM and MariaDB

install-pagekit-on-a-debian-7-vps-with-nginx-php-fpm-and-mariadbIn this blog post we will show you how to install Pagekit on a Debian 7 VPS with Nginx PHP-FPM and MariaDB. Pagekit is a new modern CMS build on top of the Symfony framework which you can use to build your website or blog.This guide should work on other Linux VPS systems as well but was tested and written for Debian 7 VPS.

 

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages.

user@vps:~# sudo apt-get update 
user@vps:~# sudo apt-get -y upgrade
user@vps:~# sudo apt-get install python-software-properties software-properties-common git vim

Install MariaDB 10.0

Add MariaDB to your sources.list

user@vps:~# sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
user@vps:~# sudo add-apt-repository 'deb http://ftp.utexas.edu/mariadb/repo/10.0/debian wheezy main'

Install MariaDB:

user@vps:~# sudo apt-get update
user@vps:~# sudo apt-get install mariadb-server

When the installation is complete, run the following command to secure your installation:

mysql_secure_installation

Next, we need to create a database for our Pagekit installation.

user@vps:~# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE pagekit;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON pagekit.* TO 'pagekituser'@'localhost' IDENTIFIED BY 'pagekituser_passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install PHP and Nginx

The latest versions of Nginx and PHP are not available via the default Debian repositories, so we will add the Dotdeb repository. Open the /etc/apt/sources.list file and append the following lines:

user@vps:~# sudo vim /etc/apt/sources.list
deb http://packages.dotdeb.org wheezy all
deb http://packages.dotdeb.org wheezy-php56 all

Fetch and install the GnuPG key:

user@vps:~# wget -qO - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -

Update the system and install Nginx, PHP and all necessary extensions:

user@vps:~# sudo apt-get update
user@vps:~# sudo apt-get install nginx 
user@vps:~# sudo apt-get install php5-fpm php5-cli php5-json php5-apcu php5-curl

Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull all the required libraries you need for your project.

user@vps:~# curl -sS https://getcomposer.org/installer | php
user@vps:~# sudo mv composer.phar /usr/local/bin/composer

Install Node Gulp and Bower

user@vps:~# curl -sL https://deb.nodesource.com/setup | sudo bash -
user@vps:~# sudo apt-get install -y nodejs
user@vps:~# sudo npm install -g bower
user@vps:~# sudo npm install -g gulp

Clone the git repository

Create a root directory for your web site and clone the git repository from github using the following commands:

user@vps:~# mkdir -p ~/yourPagekitSite.com/{public_html,logs}
user@vps:~# git clone https://github.com/pagekit/pagekit.git ~/yourPagekitSite.com/public_html

Install all dependencies and buld assets

user@vps:~# cd ~/yourPagekitSite.com/public_html
user@vps:~# composer install
user@vps:~# npm install
user@vps:~# bower install
user@vps:~# gulp

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

user@vps:~# sudo tee /etc/php5/fpm/pool.d/$(whoami).conf << EOF
[$(whoami)]
user = $(whoami)  
group = $(whoami)  
listen = /var/run/php5-fpm-$(whoami).sock  
listen.owner = $(whoami)
listen.group = $(whoami)  
listen.mode = 0666  
pm = ondemand  
pm.max_children = 5  
pm.process_idle_timeout = 10s;  
pm.max_requests = 200  
chdir = /  
EOF

Restart PHP-FPM

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
user@vps:~# sudo service php5-fpm restart

Nginx configuration

Create a new Nginx server block with the following content:

user@vps:~# sudo tee /etc/nginx/sites-available/yourPagekitSite.com << EOF
server {
    server_name yourPagekitSite.com;
    listen 80;
    root $HOME/yourPagekitSite.com/public_html;
    access_log $HOME/yourPagekitSite.com/logs/access.log;
    error_log $HOME/yourPagekitSite.com/logs/error.log;
    index index.php;
 
    location / {
        try_files \$uri \$uri/ /index.php?\$args;
    }
 
    location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\$ {
        access_log off;
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
    }
 
    location ~ \.php\$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)\$;
        fastcgi_pass unix:/var/run/php5-fpm-$(whoami).sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
 
    location ~ /\.ht {
        deny all;
    }
 
}
EOF

Test the Nginx configuration:

user@vps:~# sudo nginx -t

Activate the server block by creating a symbolic link and restart nginx:

user@vps:~# sudo ln -s /etc/nginx/sites-available/yourPagekitSite.com /etc/nginx/sites-enabled/yourPagekitSite.com
user@vps:~# sudo /etc/init.d/nginx restart

Final steps

Open your browser and type the address of your website yourPagekitSite.com, enter the database information and create your first user.

That’s it. You have successfully installed your Pagekit. For more information about Pagekit, please refer to the Pagekit website.


 

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment