Radius Desk
Radius Desk
Radius Desk
Search Edit
Trace: › install_ubuntu_nginx
Installing RADIUSdesk on
Ubuntu 16.04 using Nginx
−Table of Contents
Background
Nginx is a web server that is gaining a lot of popularity today.
It is fresh, lightweight, fast, scales well and is able to take a lot of load
without overwhelming your system.
Nginx is one of those things that will cross any web developer's path
sooner or later.
This section will cover the steps you have to go through to get
RADIUSdesk working with a LEMP stack on Ubuntu 16.04
* A LEMP stack is one of those acronyms you can impress your friends
with. It stands for Linux NginX MySQL and PHP.
What do we require
A standard Nginx install on Ubuntu is actually very simple.
The part that is more involved is to tweak Nginx to do the following:
Requirement Comment
Interpret PHP Scripts We would like the web server to call the PHP interpreter
when a page ending with .php is requested.
Be able to have access to Since we set up a LEMP server, we need to have a
the MySQL functions of MySQL server installed and accessible from PHP.
PHP
Modify the expiry date of We want files that does not change (e.g. css or images) to
http headers to encourage be cached on the client's side to make the client's
caching experience more pleasant
Compress text before they We can compress the text that flows between the client
are served to the client and the server and in this way reduce the over the
line bytes which in turn should also give the client a more
pleasant experience
Enable rewrite rules in CakePHP makes use of the .htaccess files in Apache to
CakePHP for pretty URL's enable pretty URLs. Since Nginx does not support
.htaccess files, we need to change Nginx to behave in the
same way.
HOWTO
Install Nginx
We assume you have a clean install of Ubuntu 16.04 WITHOUT Apache
installed.
To remove Apache
Install Nginx
Navigate to the IP Address of the server where you installed Nginx using
a browser to ensure Nginx serves content e.g. http://127.0.0.1
The default directory where Nginx serves its content from on Ubuntu
is /var/www/html.
Since RADIUSdesk has been developed over a couple of years, it was
traditionally served by Nginx from the /usr/share/nginx/html directory.
(This was on Ubunut 14.04).
Edit the default server file:
sudo vi /etc/nginx/sites-enabled/default
#root /var/www/html;
root /usr/share/nginx/html;
Modify Nginx
Now that the php-fpm service is installed we should change the
default Nginx server to make use of it.
Edit the default server file:
sudo vi /etc/nginx/sites-enabled/default
#add index.php
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
location ~ /\.ht {
deny all;
sudo vi /usr/share/nginx/html/test.php
Contents:
<?php
phpinfo();
?>
Install MySQL
Be sure to supply a root password for the MySQL database when asked
for it if you are security conscious else simply hit the ESC key.
sudo vi /etc/mysql/conf.d/disable_strict_mode.cnf
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIV
ISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
sudo vi /etc/nginx/sites-available/default
location ~ ^/cake2/.+\.(jpg|jpeg|gif|png|ico|js|css)$ {
rewrite ^/cake2/rd_cake/webroot/(.*)$
/cake2/rd_cake/webroot/$1 break;
access_log off;
expires max;
Reload Nginx:
sudo vi /etc/nginx/nginx.conf
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json
application/javascript text/xml application/xml
application/xml+rss text/javascript;
Restart Nginx
Install RADIUSdesk
The first part prepared everything to install RADIUSdesk. This part will go
through the steps to install the latest RADIUSdesk.
RADIUSdesk consists of three components.
rd directory with its contents contains all the HTML and JavaScript
code and is used as the presentation layer.
rd_cake is a CakePHP application and can be considered the engine
room. Here the data is processed before being presented by the
presentation layer. (We currently use one CakePHP v2 and one
CakePHP v3 application in order to migrate from CakePHP v2 to
CakePHP v3)
rd_login is a directory with various login pages which are centrally
managed through the RADIUSdesk Dynamic Login Pages applet.
Although this is optional, it is used by most installs.
We will use SVN (subversion) to check out the latest version (trunk) of
RADIUSdesk.
Install CakePHP
As from December 2016 we started a migration process of migrating
from CakePHP v2 to CakePHP v3.
The ORM component of CakePHP v3 is completely new and different
which makes the migration fairly involved.
Since the architecture of RADIUSdesk is following modern design
principles it allows us to run both CakePHP v2 and CakePHP v3
simultaneously.
We can then do the migration gradually over time.
Required packages
Make sure the following packages are installed:
Install CakePHP v2
Download the 2.x version of CakePHP (Version 2.9.7 as of this
writing). https://github.com/cakephp/cakephp/tags
There are two formats to choose from when selecting to download, Zip
or Tar.gz. Select Tar.gz.
Copy and extract it inside the directory that Nginx is serving its content
from (/usr/share/nginx/html)
cd /usr/share/nginx/html
Reload php7.0-fpm
cd /usr/share/nginx/html/cake2
cd /usr/share/nginx/html/
The Database
Create the following blank database:
sudo su
mysql -u root
exit;
USE rd;
Configure Nginx
Since CakePHP uses rewrite rules, we have to configure Nginx in such a
way as to allow rewriting of the URL's that starts with /cake2/rd_cake or
with /cake3/rd_cake.
Edit /etc/nginx/sites-enabled/default
sudo vi /etc/nginx/sites-enabled/default
location /cake2/rd_cake {
location /cake3/rd_cake {
Viewer component
Check out the latest code of the viewer component under the
/usr/share/nginx/html/ directory:
cd /usr/share/nginx/html/
For the viewer component you need the ExtJS toolkit. We've added
version 6.2.0 to the SVN repository for easy download
Checkout and unzip the GPL version under the /usr/share/nginx/html/rd
directory. NOTE: This is a single big file which will take some time to
download over slow connections.
cd /usr/share/nginx/html/
cd /usr/share/nginx/html/rd
Now try to log in on the following URL with username root and
password admin: http://127.0.0.1/rd/build/production/Rd/index.html
Alternatively (also if you do not have Internet Access on the machine) use
this URL which is a bit slower: http://127.0.0.1/rd/index.html?cache
Cron Scripts
RADIUSdesk requires a few scripts to run periodically in order to
maintain a healthy and working system.
To activate the cron scripts execute the following command, which will
add RADIUSdesk's crons scripts to the Cron system
sudo cp /usr/share/nginx/html/cake2/rd_cake/Setup/Cron/rd
/etc/cron.d/
If you want to change the default intervals at which the scripts get
executed, just edit the /etc/cron.d/rd file.
Next steps
Be sure to also install FreeRADIUS and Node.js,
Install FreeRADIUS
Install node.js
Last modified: 2017/07/06 21:17