Tag name:ubuntu

Setting up a ubuntu for my development enviroment

13th May 2021

So I'm experimenting with a new development environment - this one is a ubuntu 20.04 running inside of Oracle VM Virtual Box. The initial installation was done following the cookbook from Abhishek Prakash.

Initial VM setup

  • Download and install VirtualBox
  • Download the ISO for Ubuntu
  • Start Virtual Box and create a new VM - I specified 4GB memory, 4 processor and approx 60GB Hard Disc
  • Start the VM using the ISO image and complete the Ubuntu installation

Development Environment Setup

  • Install fossil using sudo apt install fossil
  • Install ant using sudo apt install ant
  • Install npm using sudo apt install npm
  • Install php 7.4 using sudo apt install php7.4
  • Create directory for the website development mkdir website
  • Clone the website fossil and open it:
    • fossil clone http://david:password@virtual.internal:7780/website website.fossil
    • cd website
    • fossil open ../website.fossil
  • Install prereq npm packages:
    • sudo npm -g install jshint@2.11
    • sudo npm -g install qunit@2.10
    • sudo npm -g install ajv-cli@4.0
  • Test the build by
    • cd build
    • ant rebuild-all

WordPress setup

  • Install prereqs by sudo apt install apache2 mysql-server libapache2-mod-php php-mysql
  • Configure and enable apache2 by
    • sudo systemctl start apache2
    • sudo systemctl enable apache2
    • sudo ufw allow in "Apache Full"
  • Configure mysql and setup a database for wordpress by
    • sudo mysql_secure_installation
    • sudo mysql -u root -p and enter these commands:
      • CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
      • CREATE USER wordpress IDENTIFIED WITH mysql_native_password BY '12345';
      • GRANT ALL ON wordpress.* TO 'wordpress'@'%';
      • quit
  • Install php extensions used by wordpress using sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
  • Restart apache2 using sudo systemctl restart apache2
  • Install curl using sudo apt install curl
  • Download wordpress using curl -O https://wordpress.org/latest.tar.gz
  • Extract the archive and move under apache:
    • tar -xzvf latest.tar.gz
    • sudo mv wordpress /var/www/html
    • sudo chown -R www-data:www-data /var/www/html/wordpress
    • sudo chmod -R 775 /var/www/html/wordpress
  • Setup the wordpress config:
    • cd /var/www/html/wordpress
    • sudo mv wp-config-sample.php wp-config.php
    • Edit wp-config.php to setup the credentials for the database
  • Setup the apache2 config for wordpress:
    • sudo nano /etc/apache2/sites-available/wordpress.conf
    • Make the contents to these lines:
      <Directory /var/www/html>
              Options Indexes FollowSymLinks MultiViews
              AllowOverride All
              Require all granted
      <VirtualHost *:80>
              ServerName wordpress
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www/html/wordpress
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
    • Check the config via: apache2ctl -t
    • Enable it with sudo a2ensite wordpress
    • Disable the default site with sudo a2dissite 000-default
    • Activate the new apache2 configuration with sudo systemctl restart apache2
  • Complete the wordpress install by browsing the image's website

phpMyAdmin installation

  • Install phpmyadmin via sudo apt install phpmyadmin
  • You may need to enable the apache2 conf via:
    • sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
    • sudo a2enconf phpmyadmin
    • udo systemctl reload apache2

Fixing the Simply Static plugin

18th November 2020

After updating my Ubuntu system to 20.04, I discovered that my method for generating the static version of the site no longer works. It turns out that the Simply Static plugin has a hidden dependency on PHP 7.2 (and upgrading Ubuntu from 18.04 to 20.04 incidently updates the PHP level from 7.2 to 7.4).

After doing some digging I discovered that the Simply Static plugin has an included library called PhpSimpleHtmlDom and the version in the plugin (1.5) is the culprit, I downloaded a more recent version of that library from github and replaced the version of the library with that level and (after a minor hack to change the namespace of the library to match the old namespace being used), Simply Static is now working again.

Hopefully, at some point, the author of the plugin will update it and I won't need the hack. That said the plugin has not been updated for a few years so may now be abandoned. If so I'll probably have to change the infrastructure that builds the static version of the website...

My thanks to Github user caophihung94 for providing a newer version of the PhpSimpleHtmlDom library

Sleeping until top of the minute

23rd June 2017

I recently wanted my bash script (running on Ubuntu) to sleep until the top of the minute. The suggested code snippet from goggling is:

sleep $((60 - $(date +%S) ))

This works well, unless the current seconds count is 08 or 09. Bash interprets numbers starting with 0 as octal and 08 (and 09) are not valid octal numbers. I fixed this in my script as follows:

sleep $((160 - 1$(date +%S) ))

Manually updating a Ubuntu kernel

21st May 2017

For some reason that I've yet to get to the bottom of, on my Ubuntu server box the kernel wasn't getting updated (the header files to go with the kernel definitely were, but the kernel itself seemed to stay stuck.

To manually update to a kernel level:

  • sudo apt-get install linux-image-extra-4.4.0-xx-generic

Setting up ubuntu (Apr 2017)

1st April 2017

Since I'm in the progress of setting up an Ubuntu machine on another older machine as a server I want to record my steps...

All based on Ubuntu 16.04.2 LTS

  1. To ensure latest level of Ubuntu:
    1. sudo apt-get update
    2. sudo apt-get dist-upgrade
  2. To select 2D graphic effects instead of 3D:
    1. Add the older UI via:

      sudo apt-get install gnome-session-flashback

    2. logout, and then in the login window, click on the Ubuntu logo next to your user name and select "GNOME Flashback (Metacity)".
  3. Modify Brightness and Lock to adjust the screen saver timeouts

running popfile as a daemon process

23rd February 2016

This is just a note to myself in case I need it 🙂

To run popfile as a daemon process on Ubuntu. I did the following:

  1. Created a popfile user and home directory and gave it a copy of the popfile executables and copied across its data into /var/popfile.
  2. Created a /etc/init.d/popfile file
  3. Issued
    sudo /etc/init.d/popfile start

It's worth noting that popfile has data in /var/lib/popfile when it comes to backing it up. When restoring/transferring these files I also needed to ensure that the popfile userid owns these files.

running fossil as a daemon process

23rd February 2016

This is just a note to myself in case I need it 🙂

To run fossil as a daemon process on Ubuntu. I did the following:

  1. Created a fossil user and home directory and gave it a copy of the fossil executable and the website fossil file
  2. Created a fossil/etc/init.d/fossil file
  3. Issued
    sudo /etc/init.d/fossil start
  4. Run sudo update-rc.d fossil defaults to get the init.d script run at system start.

This /etc/init.d/fossil runs multiple fossils.