Let’s Try Cubie Web Server

With XBMC on the CubieBoard a bust.  It’s time to go back to my original thought, which is to set it up as a web server.

While I will generally run this without a monitor connected, I have decided to restore from the backup that already has LXDE installed.

Yes, I could set it up without X, and just install it in the event that I actually come around to needing it, but I figured I might as well just have it installed now.  It’s not like there’s a lack of space on an 8GB MicroSD card.

As I am restoring with LXDE, I still need to setup the HDMI audio again for regular applications.

So, from the last post.

  • apt-get install pulseaudio
  • apt-get install pavucontrol

Identify the audio hardware, and put…

load-module module-alsa-sink device=hw:1,0

in /etc/pulse/default.pa

Then configure with pavucontrol.

So that I don’t have to keep setting up the sound every time I restore from the LXDE backup image, I’m going to make a new image with Win32 Disk Imager with the sound preconfigured.

So, to business.

  • apt-get update
  • cubian-update
  • apt-get install apache2
  • apt-get install php5 php-pear php5-mysql
  • /etc/init.d/apache2 restart

Apache is installed, and loading the IP address of the CubieBoard in a browser from another PC loads up the test page located in /var/www.

I then made a phpinfo.php file containing the following…

<?php phpinfo(); ?>

This loads up just fine and gives me the expected response.

Now, when I tried to replace MySQL with MariaDB on the Raspberry Pi, I only found one set of instructions that worked flawlessly.  So, big thanks to Kyle Platt for posting this.

https://plus.google.com/+KylePlatt/posts/8pmWKvbaGd2

I essentially follow that process, but with some slight modification to compensate for differences between the Raspbian and Cubian installs, and to ensure the latest version of mariadb.

5.5.34 is the current Stable version as of writing this.  With the “wget” line below, if you want to ensure you’re running the latest version, check the MariaDB website.

https://downloads.mariadb.org/

  • wget “https://downloads.mariadb.org/interstitial/mariadb-5.5.34/kvm-tarbake-jaunty-x86/mariadb-5.5.34.tar.gz/from/http://mirrors.coreix.net/mariadb”
  • tar -xvf mariadb
  • mv mariadb-5.5.34 maria
  • cd maria/BUILD
  • ./autorun.sh
  • cd ..
  • apt-get install build-essential
  • apt-get install cmake libncurses5-dev bison
  • ./configure
  • make
  • make install

Actually making it will take a while.  On the Cubie I just started it at 00:06, and it finished at 02:04.  Not bad, 1hr 58min.  On the Pi, I believe it took around two and a half hours.

Then we need to make a MySQL user and fire it up.

  • adduser mysql
  • chown -R mysql /usr/local/mysql
  • cp /usr/local/mysql/support-files/my-medium.cnf /etc/mysql/my.cnf
  • cd /usr/local/mysql
  • scripts/mysql_install_db –user=mysql
  • cp support-files/mysql.server /etc/init.d/mysqld
  • /etc/init.d/mysqld start

And this just sets up the basics, adding a root password, etc.

  • ./bin/mysql_secure_installation

Next up is getting phpMyAdmin on there, so we can add remote access to the MySQL database for root, then I can do everything from HeidiSQL from a Windows machine. Go the phpMyAdmin site and choose yourself a local mirror.

  • wget “http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.1.2/phpMyAdmin-4.1.2-all-languages.zip?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Findex.php&ts=1388457473&use_mirror=kent” -O phpMyAdmin-4.1.2.tar.gz
  • unzip phpMyAdmin-4.1.2.tar.gz
  • mv phpMyAdmin-4.1.2-all-languages phpMyAdmin
  • rm -rf phpMyAdmin-4.1.2.tar.gz

Well, phpMyAdmin doesn’t want to login after entering my username (root) and password, and HeidiSQL “is not allowed to connect to this MariaDB server”.

At this point, given how much I’ve changed things, I@m giving it a quick reboot, just to be safe.

Ok, couple of things we need to do.  Firstly…

  • mkdir /var/run/mysql
  • chown -R mysql /var/run/mysql

Next, we need to edit /etc/mysql/my.cnf and change the following line in both the [client] and [mysqld] sections, too).

socket          = /tmp/mysql.sock

So that it reads

socket          = /var/lib/mysqld/mysqld.sock

Then…

  • /etc/init.d/mysql restart
  • /etc/init.d/apache2 restart

Success!  phpMyAdmin now works!

I did actually install the mysql-client package, just to ensure that the MySQL server was indeed listening for connections and accepting them (which it was).

So, all I really needed to do was figure out the correct path that php was looking for as the “default” MySQL socket path – which I managed to do via a simple PHP script – and then change it in my.conf (I felt it was easier to just change MariaDB to the “expected defaults” than to modify PHP and god knows what else to MariaDB’s defaults).

  • <?php
  • $conn = mysql_connect(‘localhost’, ‘USER’, ‘PASSWORD’);
  • if(!$conn) {
  • echo ‘Error: ‘ . mysql_errno() . ‘ – ‘ . mysql_error();
  • }
  • ?>

Yup, I still REALLY need to change this WordPress theme.

Anyway, proof of success…

mysql_installed

And now it’s time for a quick backup of the card, and then bed!

I’m sure there are one or two issues in there which I’ll stumble upon the more I actually use the system, so I’ll deal with those as I get to them.

Once I feel I’ve squashed the majority of them, as I’ll no doubt install a lot of useless crap in the process, I’ll backup all my files & MySQL data, restore from the LXDE backup, and reinstall Apache, PHP & MariaDB all over again, but cleaner, before making a new backup.

Yes, I like backups!