{"id":580,"date":"2017-03-25T14:12:12","date_gmt":"2017-03-25T06:12:12","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=580"},"modified":"2018-09-02T23:04:24","modified_gmt":"2018-09-02T15:04:24","slug":"how-i-setup-codiad-web-ide-on-my-raspberry-pi-3-with-ubuntu-server-15-10-3-nginx-and-php","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-i-setup-codiad-web-ide-on-my-raspberry-pi-3-with-ubuntu-server-15-10-3-nginx-and-php\/","title":{"rendered":"How I setup Codiad web IDE on my Raspberry Pi 3 with Ubuntu Server 15.10.3, Nginx and PHP"},"content":{"rendered":"<p>There are times when I get the urge to work on project source codes that reside on my Raspberry Pi 3 LEMP server while I am on the move. Setting up a web based IDE on my Raspberry Pi 3 is one way to enable me to code while I am on the move, so long as I have a device with a web browser that is connected to the internet. Since I had already <a href=\"\/blog\/setting-up-a-lemp-web-server-on-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-host-a-wordpress-website\/\" target=\"_blank\">setup a LEMP server to run WordPress on my Raspberry Pi 3<\/a> and that Codiad is written in PHP, <a href=\"http:\/\/codiad.com\/\" target=\"_blank\">Codiad<\/a> is an ideal web based IDE that I can set up on my <a href=\"\/blog\/tag\/raspberry-pi-3\/\" target=\"_blank\">Raspberry Pi 3<\/a>. <\/p>\n<p>This post documents how I setup Codiad web IDE on my Raspberry Pi 3. To make this post complete, I had taken some of the steps mentioned in my other posts on <a href=\"https:\/\/www.techcoil.com\/blog\/tag\/raspberry-pi\/\" target=\"_blank\">Raspberry Pi<\/a> and replicated it in this post.<\/p>\n<h2>Getting the hardware<\/h2>\n<p>The hardware that I used for this setup is as follows:<\/p>\n<ol>\n<li>A <a href=\"https:\/\/www.amazon.com\/gp\/product\/B01CD5VC92\/ref=as_li_ss_tl?smid=A30ZYR2W3VAJ0A&psc=1&linkCode=ll1&tag=clivsperswebs-20&linkId=ea3d80d91754b72a5ed6c2cfeedf2ddb\" title=\"Amazon page for Raspberry Pi 3 Model B Mother board\" target=\"_blank\">Raspberry Pi 3 motherboard<\/a><\/li>\n<li>A <a href=\"http:\/\/www.amazon.com\/gp\/product\/B0145IWUDW?ie=UTF8&camp=1789&creativeASIN=B0145IWUDW&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for PiBlox LEGO\u00ae Compatible Case For Raspberry Pi B+ \/ Raspberry Pi 2 - Black\" target=\"_blank\">PiBlox LEGO\u00ae Compatible Case<\/a><\/li>\n<li>A <a href=\"http:\/\/www.amazon.com\/gp\/product\/B010Q57T02?ie=UTF8&camp=1789&creativeASIN=B010Q57T02&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for SanDisk Ultra 32GB microSDHC UHS-I Card with Adapter \" target=\"_blank\">SanDisk Ultra 32GB microSDHC UHS-I Card with Adapter<\/a><\/li>\n<\/ol>\n<p>As my laptop came with a SD card reader, I did not have to get a <a href=\"http:\/\/www.amazon.com\/gp\/product\/B00NNF4I5M?ie=UTF8&camp=1789&creativeASIN=B00NNF4I5M&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for Insten USB 3.0 Super Speed All-in-1 Multi Card Reader \" target=\"_blank\">SD card reader<\/a>. <\/p>\n<h2>Getting the Ubuntu Server 15.10.3 image for my Raspberry Pi 3 onto the micro SD card<\/h2>\n<p>After I got the hardware that I needed, the next step was to get the Ubuntu Server 15.10.3 image for my Raspberry Pi 3. The awesome folks at <a href=\"https:\/\/ubuntu-pi-flavour-maker.org\" title=\"Ubuntu pi flavour maker home page\" target=\"_blank\">Ubuntu Pi Flavour Maker<\/a> had made a few variations of Ubuntu images available for me to <a href=\"https:\/\/ubuntu-pi-flavour-maker.org\/download\/\" title=\"Ubuntu Pi Flavour maker download page for Raspberry Pi images \">download<\/a>. <\/p>\n<p>I downloaded a copy of the <a href=\"https:\/\/ubuntu-pi-flavour-maker.org\/wily\/ubuntu-standard-15.10.3-server-armhf-raspberry-pi-2.img.xz.torrent\" title=\"Torrent link for Ubuntu Pi Flavour Maker's Ubuntu Server Standard 15.10.3\" target=\"_blank\">Ubuntu Server Standard 15.10.3 image<\/a> onto my windows machine via torrent. <\/p>\n<p>Once I got the .xz file, I used <a href=\"http:\/\/www.7-zip.org\/download.html\" title=\"7-zip download page\" target=\"_blank\">7-zip<\/a> to extract the .img file. I then <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-prepare-the-operating-system-to-run-your-raspberry-pi-with-your-windows-machine\/\" target=\"_blank\">used Win32 Disk Imager to write the .img file<\/a> into the <a href=\"http:\/\/www.amazon.com\/gp\/product\/B010Q57T02?ie=UTF8&camp=1789&creativeASIN=B010Q57T02&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for SanDisk Ultra 32GB microSDHC UHS-I Card with Adapter \" target=\"_blank\">SanDisk microSD card<\/a> via the SD card drive on my laptop.<\/p>\n<h2>Booting into Ubuntu Server 15.10.3 on my Raspberry Pi 3<\/h2>\n<p>Once Win32 Disk Imager completed writing the Ubuntu Server 15.10.3 image onto my <a href=\"http:\/\/www.amazon.com\/gp\/product\/B010Q57T02?ie=UTF8&camp=1789&creativeASIN=B010Q57T02&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for SanDisk Ultra 32GB microSDHC UHS-I Card with Adapter \" target=\"_blank\">SanDisk microSD card<\/a>, I removed it from my SD card reader and inserted it to the SD card slot on the Raspberry Pi 3 motherboard. <strong>Note that unlike the Raspberry Pi 2, the microSD slot of the Raspberry Pi 3 motherboard is not a spring loaded one.<\/strong> This means that you just push to insert your microSD card and pull to remove your microSD card.<\/p>\n<p>I then attached my trusty <a href=\"http:\/\/www.amazon.com\/gp\/product\/B003B4BBFK?ie=UTF8&camp=1789&creativeASIN=B003B4BBFK&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for Logitech M100 USB Optical Wired Mouse\" target=\"_blank\">mouse<\/a>, <a href=\"http:\/\/www.amazon.com\/gp\/product\/B004VVLZN0?ie=UTF8&camp=1789&creativeASIN=B004VVLZN0&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for Logitech Classic Keyboard K100\" target=\"_blank\">keyboard<\/a>, <a href=\"http:\/\/www.amazon.com\/gp\/product\/B00M2UIWKQ?ie=UTF8&camp=1789&creativeASIN=B00M2UIWKQ&linkCode=xm2&tag=clivsperswebs-20\" title=\"Amazon page for Samsung Simple LED 24\" Monitor S24D300H with High Glossy Finish\" target=\"_blank\">monitor<\/a>, a RJ45 network cable from my DLink router and my old samsung charger to my Raspberry Pi 3 motherboard. After turning on the power, the login screen appears. The default username is 'ubuntu' and the password is 'ubuntu'.<\/p>\n<h2>Adding a new user<\/h2>\n<p>I do not like a default username for my web server, even though it is not going to be used as the production server. Hence, I first added a new user via the command as follows:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo adduser techcoil\r\n<\/pre>\n<p>I then went through the following Q and As:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nAdding user `techcoil' ...\r\nAdding new group `techcoil' (1000) ...\r\nAdding new user `techcoil' (1000) with group `techcoil' ...\r\nCreating home directory `\/home\/techcoil' ...\r\nCopying files from `\/etc\/skel' ...\r\nEnter new UNIX password: \r\nRetype new UNIX password: \r\npasswd: password updated successfully\r\nChanging the user information for techcoil\r\nEnter the new value, or press ENTER for the default\r\n\tFull Name &#x5B;]: Techcoil\r\n\tRoom Number &#x5B;]: #1234\r\n\tWork Phone &#x5B;]: 12345678\r\n\tHome Phone &#x5B;]: 12345678\r\n\tOther &#x5B;]: 12345678\r\n<\/pre>\n<p>After I had created my new user account, I proceeded to add it to the sudo group so that I was able to continue with installing the necessary software:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo adduser techcoil sudo\r\n<\/pre>\n<h2>Deleting the default user<\/h2>\n<p>Once I had created my user, I proceeded to delete the default user. <\/p>\n<p>I first restarted the server:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo reboot\r\n<\/pre>\n<p>After the server booted up again, I logged in with my new user.<\/p>\n<p>Once I had logged into the server, I typed the following in the terminal to delete the default user:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo deluser --remove-home ubuntu\r\n<\/pre>\n<h2>Resizing the file system of my Ubuntu Server 15.10.3 image to utilize the entire microSD card space on my Raspberry Pi 3<\/h2>\n<p>By default, the Ubuntu Server 15.10.3 image does not utilize the entire microSD card space on my Raspberry Pi 3.<\/p>\n<p>Therefore, I proceeded on to <a href=\"https:\/\/www.techcoil.com\/blog\/how-i-resized-the-file-system-of-my-ubuntu-server-15-10-3-image-to-utilize-the-entire-microsd-card-space-on-my-raspberry-pi-3\/\" title=\"How I resized the file system of my Ubuntu Server 15.10.3 image to utilize the entire microSD card space on my Raspberry Pi 3\" target=\"_blank\">resize the file system of my Ubuntu Server 15.10.3 image to utilize the entire microSD card space on my Raspberry Pi 3<\/a>.<\/p>\n<h2>Adding swap space to my Ubuntu Server 15.10.3 image<\/h2>\n<p>1 GB of ram is not going to be enough to run GitBucket alongside the other pieces that run the WordPress instance on my Raspberry Pi 3. As such, I also went on to <a href=\"https:\/\/www.techcoil.com\/blog\/adding-swap-space-for-my-ubuntu-server-15-10-3-image-running-on-my-raspberry-pi-3\/\" title=\"Adding swap space for my Ubuntu Server 15.10.3 image running on my Raspberry Pi 3\" target=\"_blank\">add swap space to the Ubuntu Server 15.10.3 image<\/a> so as to complement the 1GB of ram on my Raspberry Pi 3.<\/p>\n<h2>Installing Nginx on my Ubuntu Server 15.10.3<\/h2>\n<p>I installed Nginx with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install nginx\r\n<\/pre>\n<p>After the installation had completed, I ran the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncurl -0 localhost\r\n<\/pre>\n<p>And got the following output:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Welcome to nginx!&lt;\/title&gt;\r\n&lt;style&gt;\r\n    body {\r\n        width: 35em;\r\n        margin: 0 auto;\r\n        font-family: Tahoma, Verdana, Arial, sans-serif;\r\n    }\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;Welcome to nginx!&lt;\/h1&gt;\r\n&lt;p&gt;If you see this page, the nginx web server is successfully installed and\r\nworking. Further configuration is required.&lt;\/p&gt;\r\n\r\n&lt;p&gt;For online documentation and support please refer to\r\n&lt;a href=&quot;http:\/\/nginx.org\/&quot;&gt;nginx.org&lt;\/a&gt;.&lt;br\/&gt;\r\nCommercial support is available at\r\n&lt;a href=&quot;http:\/\/nginx.com\/&quot;&gt;nginx.com&lt;\/a&gt;.&lt;\/p&gt;\r\n\r\n&lt;p&gt;&lt;em&gt;Thank you for using nginx.&lt;\/em&gt;&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>This output assured me that my Nginx web server was successfully installed.<\/p>\n<h2>Installing PHP<\/h2>\n<p>As Codiad web IDE is written in PHP, I went on to install the PHP binary and the PHP Fast Process Manager. To do so, I ran the following commands in the terminal: <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install php5 php5-fpm\r\n<\/pre>\n<p>After the installation had completed, I entered the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl status php5-fpm\r\n<\/pre>\n<p>And got the following verification:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\u25cf php5-fpm.service - The PHP FastCGI Process Manager\r\n   Loaded: loaded (\/lib\/systemd\/system\/php5-fpm.service; enabled; vendor preset: enabled)\r\n   Active: active (running) since Wed 2016-04-06 12:52:55 UTC; 4min 59s ago\r\n Main PID: 7300 (php5-fpm)\r\n   Status: &quot;Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req\/sec&quot;\r\n   CGroup: \/system.slice\/php5-fpm.service\r\n           \u251c\u25007300 php-fpm: master process (\/etc\/php5\/fpm\/php-fpm.conf)\r\n           \u251c\u25007302 php-fpm: pool www\r\n           \u2514\u25007303 php-fpm: pool www\r\n\r\nApr 06 12:52:55 ubuntu-standard systemd&#x5B;1]: Starting The PHP FastCGI Process....\r\nApr 06 12:52:55 ubuntu-standard systemd&#x5B;1]: Started The PHP FastCGI Process ....\r\nApr 06 12:52:58 ubuntu-standard systemd&#x5B;1]: Started The PHP FastCGI Process ....\r\nHint: Some lines were ellipsized, use -l to show in full.\r\n<\/pre>\n<h2>Installing PHP modules that are required by Codiad web IDE<\/h2>\n<p>The Codiad web IDE that I had downloaded requires, mbstring, zip and openssl PHP libraries. Since mbstring and zip were not packaged with the PHP binary that I had installed in the previous step, I installed php-mbstring and php-zip by running the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install php-zip php-mbstring\r\n<\/pre>\n<h2>Downloading the latest copy of Codiad web IDE<\/h2>\n<p>At the time of this writing, the latest stable release for Codiad web IDE is v.2.7.5. To download the source code for Codiad v.2.7.5, I ran the following commands in the terminal:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/var\/www\r\nsudo wget https:\/\/github.com\/Codiad\/Codiad\/archive\/v.2.7.5.tar.gz\r\nsudo tar -xvzf v.2.7.5.tar.gz\r\nsudo rm v.2.7.5.tar.gz\r\n<\/pre>\n<p>After the commands had completed, I got the Codiad web IDE source code at <code>\/var\/www\/Codiad-v.2.7.5<\/code>.<\/p>\n<h2>Changing the owner of the <code>\/var\/www\/Codiad-v.2.7.5<\/code> directory to www-data<\/h2>\n<p>In order for Codiad to work, we will need to give write permissions to the <code>www-data<\/code> user. Hence, I ran the following command to change the owner of the <code>\/var\/www\/Codiad-v.2.7.5<\/code> directory to the <code>www-data<\/code> user:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo chown -R www-data:www-data Codiad-v.2.7.5\/\r\n<\/pre>\n<h2>Creating a type A DNS record to point Codiad Web IDE<\/h2>\n<p>After I had gotten the prerequisites to run Codiad on my Raspberry Pi 3, I went ahead to <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-and-test-dns-subdomains-with-digitalocean-s-dns-panel\/?refcode=68b7d9b94341&utm_campaign=Referral_Invite&utm_medium=Referral_Program\" target=\"_blank\">create a type A DNS record<\/a> to point to the Codiad Web IDE instance hosted on my Raspberry Pi 3. To do so, I leverage on <a href=\"https:\/\/m.do.co\/c\/68b7d9b94341\" target=\"_blank\">Digital Ocean<\/a> to create a subdomain from one of my existing URL to point to the public IP address that my ISP had given my home router. <\/p>\n<h2>Configuring Nginx to serve Codiad web IDE via URL for initial setup<\/h2>\n<p>With the type A DNS record created, Digital Ocean's name server will send the web browser the public IP address of my home router, which has a Network Address Translation entry to point to the private IP address of my Raspberry Pi. With that public IP address, the web browser will be able to establish a TCP\/IP connection to send HTTP requests over to my Raspberry Pi 3. Each HTTP request that it sends will have the following header:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nHost: ide.anexistingurl.com\r\n<\/pre>\n<p>With this header, I would then need to configure the Nginx server running on my Raspberry Pi 3 to<\/p>\n<ol>\n<li>redirect HTTP requests tagged with Host: ide.anexistingurl.com over to the PHP FPM server.<\/li>\n<li>tell the PHP FPM server to use the PHP codes in \/var\/www\/Codiad-v.2.7.5 to serve the HTTP requests.<\/li>\n<\/ol>\n<p>To do so, I first ran nano to create a new configuration file inside the <code>\/etc\/nginx\/sites-enabled<\/code> directory:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/sites-enabled\/ide.anexistingurl.com.conf\r\n<\/pre>\n<p>And populate the <code>\/etc\/nginx\/sites-enabled\/ide.anexistingurl.com.conf<\/code> with the following contents:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n\tlisten   80;\r\n\troot \/var\/www\/Codiad-v.2.7.5;\r\n\tindex index.php index.html;\r\n\r\n\tserver_name ide.anexistingurl.com;\r\n\r\n\tlocation \/ {\r\n\t\t# First attempt to serve request as file, then\r\n\t\t# as directory, then fall back to index.html\r\n\t\ttry_files $uri $uri\/ \/index.html;\r\n\t}\r\n\r\n\terror_page 404 \/404.html;\r\n\r\n\t# redirect server error pages to the static page \/50x.html\r\n\terror_page 500 502 503 504 \/50x.html;\r\n\tlocation = \/50x.html {\r\n\t\troot \/usr\/share\/nginx\/www;\r\n\t}\r\n\r\n\t# pass the PHP scripts to FastCGI server \r\n\tlocation ~ \\.php$ {\r\n                fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n\r\n                fastcgi_index index.php;\r\n                include fastcgi_params;\r\n                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n                fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n\t}\r\n}\r\n<\/pre>\n<h2>Configuring a free SSL certificate with Let's Encrypt<\/h2>\n<p>A SSL certificate will ensure that the communication between my browser and my Codiad Web IDE server endpoint remain encrypted. And with <a href=\"https:\/\/letsencrypt.org\/\" target=\"_blank\">Let's Encrypt<\/a>, I was able to <a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-a-free-ca-signed-ssl-certificate-from-lets-encrypt-for-my-lemp-server-on-my-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-secure-my-wordpress-site\/\" target=\"_blank\">create a free SSL certificate with a trusted Certificate Authority<\/a>. Hence, with Let's Encrypt, I will be able to have secured connections from my browser to my Codiad Web IDE running on my Raspberry Pi 3, without any warnings from my browser that the SSL certificate that it received was not issued by a trusted certificate authority.<\/p>\n<h3>Allowing traffic to \/.well-known uri path<\/h3>\n<p>The \/.well-known uri path would be accessed by Let's Encrypt server to validate that I was running the Let's Encrypt client on my Raspberry Pi 3 during the generation of the SSL certificate. Hence, I added the following location block in the previous Nginx configuration:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\tlocation ~ \/.well-known {\r\n\t\tallow all;\r\n\t}\r\n<\/pre>\n<p>The addition of the location block resulted in the following Nginx configuration:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n\tlisten   80;\r\n\troot \/var\/www\/Codiad-v.2.7.5;\r\n\tindex index.php index.html;\r\n\r\n\tserver_name ide.anexistingurl.com;\r\n\r\n\tlocation ~ \/.well-known {\r\n\t\tallow all;\r\n\t}\r\n\r\n\tlocation \/ {\r\n\t\t# First attempt to serve request as file, then\r\n\t\t# as directory, then fall back to index.html\r\n\t\ttry_files $uri $uri\/ \/index.html;\r\n\t}\r\n\r\n\terror_page 404 \/404.html;\r\n\r\n\t# redirect server error pages to the static page \/50x.html\r\n\terror_page 500 502 503 504 \/50x.html;\r\n\tlocation = \/50x.html {\r\n\t\troot \/usr\/share\/nginx\/www;\r\n\t}\r\n\r\n\t# pass the PHP scripts to FastCGI server \r\n\tlocation ~ \\.php$ {\r\n                fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n\r\n                fastcgi_index index.php;\r\n                include fastcgi_params;\r\n                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n                fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n\t}\r\n}\r\n<\/pre>\n<p>I then restarted Nginx to take the configuration changes:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<h3>Getting the Let's Encrypt client application to create a free certified SSL certificate and the corresponding private key<\/h3>\n<p>With the uri ready for validation, I then proceeded to get the Let's Encrypt client application.<\/p>\n<p>I first installed Git:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-add-repository ppa:git-core\/ppa\r\nsudo apt-get update\r\nsudo apt-get install git -y\r\n<\/pre>\n<p>And then use Git to clone a copy of the Let's Encrypt client application onto the local file system of my Raspberry Pi 3:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/opt\r\nsudo git clone https:\/\/github.com\/letsencrypt\/letsencrypt.git\r\n<\/pre>\n<p>After the cloning had completed, I then ran the Let's Encrypt client application:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/opt\/letsencrypt\/letsencrypt-auto certonly -a webroot --webroot-path=\/var\/www\/Codiad-v.2.7.5 -d ide.anexistingurl.com \r\n<\/pre>\n<h3>Generating a strong Diffie-Hellman group<\/h3>\n<p>I also generated a strong Diffie-Hellman group for Openssl to perform the Diffie-Hellman (DH) key-exchange:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo openssl dhparam -out \/etc\/ssl\/certs\/dhparam.pem 2048\r\n<\/pre>\n<h3>Configuring Nginx to use the Let's Encrypt SSL certificate and private key for serving HTTPS traffic<\/h3>\n<p>I opened up \/etc\/nginx\/sites-enabled\/ide.anexistingurl.com.conf which I had created earlier:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/sites-enabled\/ide.anexistingurl.com.conf\r\n<\/pre>\n<p>and replaced its contents with the following text:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n        listen   80;\r\n        server_name ide.anexistingurl.com;\r\n        return 301 https:\/\/$host$request_uri;\r\n}\r\n\r\n# For ssl\r\nserver {\r\n        ssl on;\r\n\r\n        ssl_certificate \/etc\/letsencrypt\/live\/ide.anexistingurl.com\/fullchain.pem;\r\n        ssl_certificate_key \/etc\/letsencrypt\/live\/ide.anexistingurl.com\/privkey.pem;\r\n        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n        ssl_prefer_server_ciphers on;\r\n        ssl_dhparam \/etc\/ssl\/certs\/dhparam.pem;\r\n        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DH$\r\n        ssl_session_timeout 1d;\r\n        ssl_session_cache shared:SSL:50m;\r\n        ssl_stapling on;\r\n        ssl_stapling_verify on;\r\n        add_header Strict-Transport-Security max-age=15768000;\r\n        default_type application\/octet-stream;\r\n        listen 443;\r\n\r\n        root \/var\/www\/Codiad-v.2.7.5;\r\n        index index.php index.html;\r\n\r\n        server_name ide.anexistingurl.com;\r\n\r\n        location ~ \/.well-known {\r\n                allow all;\r\n        }\r\n\r\n        location \/ {\r\n                # First attempt to serve request as file, then\r\n                # as directory, then fall back to index.html\r\n                try_files $uri $uri\/ \/index.html;\r\n        }\r\n\r\n        error_page 404 \/404.html;\r\n\r\n        # redirect server error pages to the static page \/50x.html\r\n        error_page 500 502 503 504 \/50x.html;\r\n        location = \/50x.html {\r\n                root \/usr\/share\/nginx\/www;\r\n        }\r\n\r\n        # pass the PHP scripts to FastCGI server\r\n        location ~ \\.php$ {\r\n                fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\r\n\r\n                fastcgi_index index.php;\r\n                include fastcgi_params;\r\n                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n                # With php5-fpm (or php7-fpm, ie on Ubuntu 16.04):\r\n                fastcgi_pass unix:\/var\/run\/php5-fpm.sock;\r\n        }\r\n}\r\n<\/pre>\n<p>The first server block would make my Nginx server listen on port 80 for requests reaching ide.anexistingurl.com and redirect all traffic to its HTTPS counterpart.<\/p>\n<p>The second server block would configure my Nginx server to serve SSL traffic on port 443 for ide.anexistingurl.com. In that block, I point my server to the strong Diffie-Hellman group, the Let's Encrypt certified SSL certificate and the private key.<\/p>\n<p>I kept the location block to requests made to the \/.well-known prefix so that I could renew my SSL certificate for ide.anexistingurl.com with the Let's Encrypt client application in the future.<\/p>\n<p>With the that, I restarted Nginx to take the configuration changes for my Nginx to serve HTTPS requests for my Codiad Web IDE:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<h2>Specifying the directories where Codiad IDE can take as absolute paths for the projects that I want to work on<\/h2>\n<p>By default, Codiad IDE only allows absolute path to projects contained in its own source code root directory and <code>\/home<\/code>. Since I want to work on projects that are contained in \/var\/www, I opened up \/var\/www\/Codiad-v.2.7.5\/config.php:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/var\/www\/Codiad-v.2.7.5\/config.php\r\n<\/pre>\n<p>and changed the following line:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\ndefine(&quot;WHITEPATHS&quot;, BASE_PATH . &quot;,\/home&quot;);\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\ndefine(&quot;WHITEPATHS&quot;, BASE_PATH . &quot;,\/home,\/var\/www\/&quot;);\r\n<\/pre>\n<h2>Completing the initial setup for Codiad<\/h2>\n<p>Once my Nginx server had restarted successfully, I used my web browser to access ide.anexistingurl.com and was returned the following screen: <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/codiad-initial-setup.gif\" alt=\"Codiad initial setup screen shot\"\/><\/p>\n<p>This screen allowed me to create my first Codiad IDE user with a first project to work on. The directory that I provided in this screen had to be owned by the www-data user; if not, Codiad web IDE will not be able to use that directory to work on the source codes within that directory.  <\/p>\n<p>After I had filled in the fields and clicked the install button, I got the following screen to work on the source codes that was contained within the directory that I had supplied in the previous screen:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Codiad-project-explorer-screenshot.gif\" alt=\"Codiad project explorer screen shot\"\/><\/p>\n<p>In this case, I had supplied the directory where I had placed my Codiad Web IDE as the project that I want to work on.<\/p>\n<h2>Buying the Raspberry Pi 3 hardware to host your own Codiad Web IDE<\/h2>\n<p>If you do not have the Raspberry Pi 3 hardware mentioned in this post yet, you may want to purchase them from Amazon. Simply click on the button below to add the Raspberry Pi 3 hardware to your cart. You may remove anything that you already have or replace some of the hardware with other hardware.<\/p>\n<p><center><\/p>\n<form action=\"https:\/\/www.amazon.com\/gp\/aws\/cart\/add.html\" method=\"GET\" target=\"_blank\"><input name=\"AssociateTag\" type=\"hidden\" value=\"clivsperswebs-20\"><input name=\"SubscriptionId\" type=\"hidden\" value=\"[AKIAIMND5UBCQU2HRSUA]\"><input name=\"ASIN.1\" type=\"hidden\" value=\"B01CD5VC92\"><input name=\"Quantity.1\" type=\"hidden\" value=\"1\"><input name=\"ASIN.2\" type=\"hidden\" value=\"B0145IWUDW\"><input name=\"Quantity.2\" type=\"hidden\" value=\"1\"><input name=\"ASIN.3\" type=\"hidden\" value=\"B010Q57T02\"><input name=\"Quantity.3\" type=\"hidden\" value=\"1\"><br \/>\n<input alt=\"Buy from Amazon.com\" name=\"add\" type=\"image\" src=\"https:\/\/images-na.ssl-images-amazon.com\/images\/G\/01\/associates\/remote-buy-box\/buy4.gif\" value=\"Buy from Amazon.com\"><\/form>\n<p><\/center><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-9m\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-9m&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-9m&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F580&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>There are times when I get the urge to work on project source codes that reside on my Raspberry Pi 3 LEMP server while I am on the move. Setting up a web based IDE on my Raspberry Pi 3 is one way to enable me to code while I am on the move, so long as I have a device with a web browser that is connected to the internet. Since I had already <a href=\"\/blog\/setting-up-a-lemp-web-server-on-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-host-a-wordpress-website\/\" target=\"_blank\">setup a LEMP server to run WordPress on my Raspberry Pi 3<\/a> and that Codiad is written in PHP, <a href=\"http:\/\/codiad.com\/\" target=\"_blank\">Codiad<\/a> is an ideal web based IDE that I can set up on my <a href=\"\/blog\/tag\/raspberry-pi-3\/\" target=\"_blank\">Raspberry Pi 3<\/a>. <\/p>\n<p>This post documents how I setup Codiad web IDE on my Raspberry Pi 3. To make this post complete, I had taken some of the steps mentioned in my other posts on <a href=\"https:\/\/www.techcoil.com\/blog\/tag\/raspberry-pi\/\" target=\"_blank\">Raspberry Pi<\/a> and replicated it in this post.<\/p>\n","protected":false},"author":1,"featured_media":1166,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[424,390,389,225,13,243,240,308,423,255,195,224,391],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Raspberry-Pi-3-with-Codiad-Web-IDE-window-as-the-background.jpg","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-9m","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/580"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=580"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1166"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}