RADIUSdesk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
getting_started:18_install_ubuntu_nginx [2019/12/19 06:10] – created admingetting_started:18_install_ubuntu_nginx [2019/12/19 12:27] (current) – [Install RADIUSdesk] admin
Line 1: Line 1:
 ====== Installing RADIUSdesk on Ubuntu 18.04 using Nginx ====== ====== Installing RADIUSdesk on Ubuntu 18.04 using Nginx ======
-  * Since there is such a huge difference between the way of doing things in Ubuntu 16.04 and Ubuntu 18.04 we felt that adding this section will help those who are getting used to this newer way of doing things. 
-  * For this we assume you have a bare VM (like the ones from https://www.osboxes.org/ubuntu-server/ ) 
-  * We also assume you used this to create a VM in Virtualbox and are now faced with only the local loopback interface (127.0.0.1) when issuing the **ifconfig** command. 
- 
 ===== Background ===== ===== Background =====
  
Line 30: Line 26:
 ===== HOWTO ===== ===== HOWTO =====
 ==== Networking Introduction on Ubuntu 18.04  ==== ==== Networking Introduction on Ubuntu 18.04  ====
 +  * If you do not yet have a working network configuration on the server you plan to do the installation on, please use this section as reference, else just proceed to the next section.
 +  * Since there is such a huge difference between the way of doing things in Ubuntu 16.04 and Ubuntu 18.04 we felt that adding this section will help those who are getting used to this newer way of doing things.
 +  * For this we assume you have a bare VM (like the ones from https://www.osboxes.org/ubuntu-server/ )
 +  * We also assume you used this to create a VM in Virtualbox and are now faced with only the local loopback interface (127.0.0.1) when issuing the **ifconfig** command.
 +  * To see which interfaces are available (yet some might just not yet be configured)
 +<code bash>
 +ip a
 + </code>
 +  * On my system it lists three since I plan to use the VM also as a router with Coova Chilli running on the one interface. So we have **lo**, **enp0s3** and **enp0s8**.
 +  * For now I will just configure both of those interfaces to be DHCP clients.
 +<code bash>
 +sudo vi /etc/netplan/50-cloud-init.yaml
 + </code>
 +  * We edit the file to look like this (adapt to fit your system's interfaces)
 +<code bash>
 +# This file is generated from information provided by
 +# the datasource.  Changes to it will not persist across an instance.
 +# To disable cloud-init's network configuration capabilities, write a file
 +# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
 +# network: {config: disabled}
 +network:
 +    version: 2
 +    ethernets:
 +            enp0s3:
 +                    addresses: []
 +                    dhcp4: true
 +                    optional: true
 +            enp0s8:
 +                    addresses: []
 +                    dhcp4: true
 +                    optional: true
 +</code>
 +  * Apply the network configuration using command:
 +<code bash>
 +sudo netplan --debug apply
 +</code>
 +  * If all went well our VM will now have an IP Address (via DHCP) which we can use.
 +<code bash>
 +ip addr
 +#Feedback contains
 +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
 +    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 +    inet 127.0.0.1/8 scope host lo
 +       valid_lft forever preferred_lft forever
 +    inet6 ::1/128 scope host
 +       valid_lft forever preferred_lft forever
 +2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
 +    link/ether 08:00:27:fe:57:09 brd ff:ff:ff:ff:ff:ff
 +    inet 192.168.1.111/24 brd 192.168.1.255 scope global dynamic enp0s3
 +       valid_lft 255675sec preferred_lft 255675sec
 +    inet6 fe80::a00:27ff:fefe:5709/64 scope link
 +       valid_lft forever preferred_lft forever
 +3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
 +    link/ether 08:00:27:8c:d3:32 brd ff:ff:ff:ff:ff:ff
 +    inet6 fe80::a00:27ff:fe8c:d332/64 scope link
 +       valid_lft forever preferred_lft forever
 +</code>
 +  * Now that we have a working network setup on our machine we can continue.
 +
 ==== Install Nginx ==== ==== Install Nginx ====
   * We assume you have a clean install of Ubuntu 18.04 **WITHOUT** Apache installed.   * We assume you have a clean install of Ubuntu 18.04 **WITHOUT** Apache installed.
Line 35: Line 90:
   * To remove Apache   * To remove Apache
    <code bash>    <code bash>
-   sudo systemctl start apache2.service+   sudo systemctl stop apache2.service
    sudo apt-get remove apache2    sudo apt-get remove apache2
    </code>    </code>
 </WRAP> </WRAP>
  
 +  * Make sure it is up to date.
 +<code bash>
 +# Get the latest package lists
 +sudo apt-get update
 +# Update the system to the latest
 +sudo apt-get upgrade
 +</code>
   * Ensure the English language pack is installed   * Ensure the English language pack is installed
 <code bash> <code bash>
Line 74: Line 136:
 <code bash> <code bash>
 sudo apt-get install php-fpm sudo apt-get install php-fpm
 +sudo systemctl enable php7.2-fpm
 +sudo systemctl start php7.2-fpm
 </code> </code>
  
Line 94: Line 158:
                 include snippets/fastcgi-php.conf;                 include snippets/fastcgi-php.conf;
         #         #
-        #       # With php7.0-cgi alone:+        #       # With php-fpm (or other unix sockets): 
 +        # ===HEADS-UP We use 7.2 and NOT 7.0 as commented out === 
 +                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 
 +        #       # With php-cgi (or other tcp sockets):
         #       fastcgi_pass 127.0.0.1:9000;         #       fastcgi_pass 127.0.0.1:9000;
-        #       # With php7.0-fpm: +     }
-                fastcgi_pass unix:/run/php/php7.0-fpm.sock; +
-        }+
 </code> </code>
   * Enable the hiding of .htaccess files   * Enable the hiding of .htaccess files
Line 130: Line 195:
 <code bash> <code bash>
 sudo apt-get install mysql-server php-mysql sudo apt-get install mysql-server php-mysql
 +sudo systemctl enable mysql
 </code> </code>
  
 === Disable strict mode  === === Disable strict mode  ===
-  * With the 16.04 release of MySQL there were some changes to the MySQL configuration which causes problems on the current RADIUSdesk database implementation.+  * With the 18.04 release of MySQL there were some changes to the MySQL configuration which causes problems on the current RADIUSdesk database implementation.
   * We will disable Strict SQL Mode in MySQL 5.7.   * We will disable Strict SQL Mode in MySQL 5.7.
 <code bash> <code bash>
Line 147: Line 213:
 sudo systemctl restart mysql.service sudo systemctl restart mysql.service
 </code> </code>
- 
  
 ----- -----
Line 161: Line 226:
     rewrite ^/cake2/rd_cake/webroot/(.*)$ /cake2/rd_cake/webroot/$1 break;     rewrite ^/cake2/rd_cake/webroot/(.*)$ /cake2/rd_cake/webroot/$1 break;
     rewrite ^/cake2/rd_cake/(.*)$ /cake2/rd_cake/webroot/$1 break;     rewrite ^/cake2/rd_cake/(.*)$ /cake2/rd_cake/webroot/$1 break;
 +    access_log off;
 +    expires max;
 +    add_header Cache-Control public;
 +}
 +
 +location ~ ^/cake3/.+\.(jpg|jpeg|gif|png|ico|js|css)$ {
 +    rewrite ^/cake3/rd_cake/webroot/(.*)$ /cake3/rd_cake/webroot/$1 break;
 +    rewrite ^/cake3/rd_cake/(.*)$ /cake3/rd_cake/webroot/$1 break;
     access_log off;     access_log off;
     expires max;     expires max;
Line 170: Line 243:
 sudo systemctl reload nginx.service sudo systemctl reload nginx.service
 </code> </code>
-=== Compress the text before sending it to client === 
-  * Edit the main config file of **Nginx**. 
-<code bash> 
-sudo vi /etc/nginx/nginx.conf 
-</code> 
-  * Change the compression section to contain the following: 
-<file> 
-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; 
- 
-</file> 
-  * Restart Nginx 
-<code bash> 
-sudo systemctl restart nginx.service 
-</code> 
- 
 ---------- ----------
  
Line 200: Line 250:
     * **rd** directory with its contents contains all the HTML and JavaScript code and is used as the presentation layer.     * **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_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.+    * **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.   * We will use SVN (subversion) to  check out the latest version (trunk) of RADIUSdesk.
  
 === Install CakePHP === === Install CakePHP ===
-<WRAP center round info 100%> 
-  * 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. 
-</WRAP> 
- 
 == Required packages == == Required packages ==
  
   * Make sure the following packages are installed:   * Make sure the following packages are installed:
 <code bash> <code bash>
-sudo apt-get install php-cli php-gd php-curl php-xml php-mbstring php-intl+sudo apt-get install php-cli php-mysql php-gd php-curl php-xml php-mbstring php-intl 
 </code> </code>
  
 == Install CakePHP v2 == == Install CakePHP v2 ==
  
-  * Download the 2.x version of CakePHP (Version 2.9.as of this writing). https://github.com/cakephp/cakephp/tags+  * Download the 2.x version of CakePHP (Version 2.10.19 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.   * 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)   * Copy and extract it inside the directory that Nginx is serving its content from (/usr/share/nginx/html)
 <code bash> <code bash>
-sudo cp 2.9.7.tar.gz /usr/share/nginx/html+sudo cp 2.10.19.tar.gz /usr/share/nginx/html
 cd /usr/share/nginx/html cd /usr/share/nginx/html
-sudo tar -xzvf 2.9.7.tar.gz  +sudo tar -xzvf 2.10.19.tar.gz  
-sudo ln -s ./cakephp-2.9../cake2+sudo ln -s ./cakephp-2.10.19 ./cake2
 </code> </code>
-  * Reload php7.0-fpm+  * Reload php7.2-fpm
 <code bash> <code bash>
-sudo systemctl reload php7.0-fpm.service+sudo systemctl reload php7.2-fpm.service
 </code> </code>
  
Line 292: Line 335:
     sudo mysql -u root rd < /usr/share/nginx/html/cake3/rd_cake/setup/db/rd.sql     sudo mysql -u root rd < /usr/share/nginx/html/cake3/rd_cake/setup/db/rd.sql
 </code> </code>
- 
-<WRAP center round tip 80%> 
-  * If you have a small server like a Raspberry Pi you, run the following SQL for better performance. 
-<code sql> 
-use rd; 
-delete from phrase_values where language_id=16 OR language_id=15 or language_id=13 or language_id=5 or language_id=14; 
-</code> 
-</WRAP> 
- 
 === Configure Nginx === === 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.   * 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.
Line 360: Line 394:
 ===== Next steps ===== ===== Next steps =====
   * Be sure to also install **FreeRADIUS** and **Node.js**,   * Be sure to also install **FreeRADIUS** and **Node.js**,
-  * [[Getting Started:install_ubuntu_freeradius_3|Install FreeRADIUS]] +  * [[Getting Started:18_install_ubuntu_freeradius_3|Install FreeRADIUS]] 
-  * [[getting_started:install_ubuntu_node_js|Install node.js]]+  * [[getting_started:18_install_ubuntu_node_js|Install node.js]]