Bobcares

How to Deploy Kohana PHP application on Debian

by | Jan 12, 2021

Are you looking for steps to deploy Kohana on Debian? Take a peek at this blog.

Here at Bobcares, we have seen several such Debian related queries as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at how to set up Laravel with Nginx on Ubuntu 16.04

 

Know more about Kohana

Kohana is an HMVC (Hierarchical Model View Controller) light framework. It offers all the necessary tools out-of-the-box in order to build a modern web application.

It is mainly made of files that are scattered across carefully structured directories inside a single (application) one. So it means that each Kohana package can be considered as a web application.

The design of Kohana makes it extremely friendly for deployment.

 

Preparing the System to deploy Kohana Application

Now let’s take a look at how our Support Engineers prepare the system before deploying Kohana.

Here we are considering a newly instantiated Ubuntu 13 VPS.

First, we update the system by executing the below commands.

aptitude update
aptitude -y upgrade

Next, we install Nginx.

aptitude -y install nginx

After that, we start the server by running the below command.

service nginx start

Now, we will install MySQL 5.

aptitude -y install mysql-server mysql-client

Note: During the installation process a couple of questions regarding the root password will be asked.

We bootstrap everything using mysql_secure_installation:

# Run the following to start the process
mysql_secure_installation

# Enter the root password you have chosen during installation
# Continue with answering the questions, confirming all.
# Ex.:
# Remove anonymous users? [Y/n] Y
# Disallow root login remotely? [Y/n] Y
# ..
# .

To restart and check the status of MySQL installation, we run the below commands.

# mysql stop/waiting
# mysql start/running, process 25012
# mysql start/running, process 25012

We install PHP (PHP-FPM) by running the below command.

aptitude -y install php5 php5-fpm php5-mysql

Also, it will install the PHP5 commons.

 

Configuring the System

After installing the necessary tools, now we shall configure the system.

 

Configuring PHP

First, we configure PHP by editing the php.ini file. For that, we open the file by running the below command.

nano /etc/php5/fpm/php.ini

Then we scroll down the document and find the line ;cgi.fix_pathinfo=1. We modify it similar to the following to have application paths processed securely:

# Replace ;cgi.fix_pathinfo=1 with:
cgi.fix_pathinfo=0

Finally, we save and exit the file by pressing CTRL+X and confirm with Y.

 

Configuring Nginx

We will edit the default Nginx website configuration file. For that, we run the below command to open the file.

nano /etc/nginx/sites-available/default

Next, we copy and paste the below content:

server {

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

# Set the default application path root
# We are using my_app to host the application
root /var/www/my_app;
index index.php;

# Replace the server_name with your own
server_name localhost;

location /
{
try_files $uri /index.php?$args;

if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php/$1 last;
}
}

location ~ /\.
{
deny all;
}

location ~ \.php$
{
try_files $uri = 404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}

Finally, we save and exit by pressing CTRL+X and confirm with Y.

Then we create and enter the application deployment directory /var/www:

mkdir /var/www
cd /var/www

After that, we test the configurations and restart Nginx for the chances to take effect:

nginx -t
service nginx restart

 

Deploying A Kohana Web-Application on Debian

Now let’s see how our Support Engineers deploy Kohana.

This process comprises 2 main steps.

  • Uploading the code base to the server
  • Modifying bootstrap.php to ensure it is set correctly.

 

1. Uploading the Code Base To The Server

Now, we need to transfer the file. So we can use SFTP or a graphical tool, such as FileZilla.

First, we download Kohana.

wget https://github.com/kohana/kohana/releases/download/v3.3.1/kohana-v3.3.1.zip

Next, we install *unzip* before extracting the files

aptitude install -y unzip

Then we unzip and extract the files

unzip kohana-v3.3.1.zip -d my_app

After that, we remove the zip package.

rm -v kohana-v3.3.1.zip

Then we enter the application directory

cd my_app

 

2. Bootstrapping the Deployment (Installation)

We run the following command to start editing the configuration file using nano:

nano application/bootstrap.php

Then we edit the timezone.

date_default_timezone_set('Europe/London');

After that, we set the locale.

setlocale(LC_ALL, 'en_UK.utf-8');

We find end edit the base_url to match the installation

Kohana::init(array(
'base_url' => '/',
));

Also, we make sure to enable all necessary modules:

# Find Kohana::modules and uncomment them

Kohana::modules(array(
'auth' => MODPATH.'auth', // Basic authentication
'cache' => MODPATH.'cache', // Caching with multiple backends
'codebench' => MODPATH.'codebench', // Benchmarking tool
'database' => MODPATH.'database', // Database access
'image' => MODPATH.'image', // Image manipulation
'orm' => MODPATH.'orm', // Object Relationship Mapping
'oauth' => MODPATH.'oauth', // OAuth authentication
'pagination' => MODPATH.'pagination', // Paging of results
'unittest' => MODPATH.'unittest', // Unit testing
'userguide' => MODPATH.'userguide', // User guide and API documentation
));

Finally, we save and exit by pressing CTRL+X and confirm with Y.

Also, we set cache and log directories writable:

sudo chmod -R a+rwx application/cache
sudo chmod -R a+rwx application/logs

That’s it! Now we have our Kohana web application ready to run.

[Need any further assistance with Debian related queries? – We’re available 24*7]

 

Conclusion

Today, we saw how our Support Engineers deploy Kohana on Debian

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.