This tutorial was accurate for October of 2017. As with any Linux distro and moreso software in general, procedures and configurations are prone to change. Hopefully I have kept this updated, however, if something is no longer current or working. Please let me know email@example.com
The basic things needed for this are just an Odroid-c2 with microSD card (or emmc module) and a working internet connection (through wifi or ethernet). Everything else is extra and up to the user.
My setup remains pretty basic:
Archlinux and subsequently ArchlinuxArm is probably one of the best distros out there in my opinion. Putting the community aside, the organization of the core OS is logical, allows freedom of doing things the way you want, and provides some of the best tools to build and maintain software packages. The package manager, pacman, is one of the cleanest I have seen from any of the very many distros I have tried. The community can be harsh and rather focus minded when it comes to getting help. Luckily there are enough guides and tutorials around that a user really does not have to interact with the community if they do not have too.
Installing Archlinux is quite easy. They ship their OS as a tarball that you just have to unpack and put into place on a mounted sdcard. Before doing that, there are a few things that need to be done.
It is important that the SDCard is clean before installing a new OS.
# dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=2048
This will dump nothing but zeros in the first 2048MBs of the SDCard. It may take a while so sit tight.
The quickest and easies ways to create the partitions is using
fdisk. It does not have a super friendly GUI but with a little reading and caution, it is a very simple to use tool that does what you need.
Start fdisk with:
# fdisk /dev/mmcblk0
This will take you to a a new prompt. The next few keys and lines can be altered how you like but it is best to do it the way intended.
Press o to clear out any partitions on the SDCard. Verify that all partitions are gone by pressing p. Press n for a new partition Press p for primary partition Press 1 for the first partition on the drive Press Enter twice to select the default starting and ending points (sectors). Write the partition table and exit by typing w.
Once you are done you may need to reprobe the partition table of the SDCard into the kernel so that the partitions show up.
# partprobe /dev/mmcblk0
And you can check that the partitions looks good by using
$ lsblk -f
A partition is a block of space on a disk. A filesystem lives inside of that block of space and controls the way information is written to the disk. Creating partitions is easy and can be done with one command.
# mkfs.ext4 /dev/mmcblk0p1
Note that there is a p1 at the end of the location. It is all pretty self explanitory but the title stands for MultiMedia Card Block Device 0, partition 1
Once the filesystem is created, you can mount it
$ mkdir root
This doesn't have to be named root but it helps you to know what it is, its your
$ sudo mount /dev/mmcblk0p1 root/
Arhclinuxarm has a clever way to provide you with the closest (and thus fastest if everything is working properly) mirror to your location. All you have to do is use
wget to download the archive
$ wget http://archlinuxarm.org/os/ArchLinuxARM-odroid-c2-latest.tar.gz
Once the archive finishes downloading, you should be able to extract it into your
root/ directory that we created earlier
# bsdtar -xpf ArchLinuxARM-odroid-c2-latest.tar.gz -C root
The odroid-c2 has a file that contains some of the things that the bootloader needs in order to boot your OS. It is included in the Archlinuxarm Archive, all you have to do is flash it.
# sh root/boot/sd_fusing.sh /dev/mmcblk0p1
Once all of the installation steps are completed, you are free to unmount the sdcard and try to boot.
# umount root/
If you boot successfully, the first thing you need to do is fully update the system. Archlinux is a rolling-release distro so there are usually updates daily.
# pacman -Syyu
LAMP stands for Linux, Apache, Mysql, and PHP. These are the core tools needed to run a capable web server. Apache is the server itself however, Mysql and PHP can extend the functionality by allowing a range of services that make our life a bit easier. There are several alternatives to the LAMP stack and even an equivalent WAMP stack that replaces the Linux component with Windows. For this tutorial, LAMP is the most straight forward in its configuration. It also works extremely well for the majority of services available.
The ultimate goal of this tutorial is to end with an installation of Grav which is a flat-file CMS. Being a flat-file CMS, it does not require a database to store its data such as pages. The pages are kept as normal files in the server directory. Even though we will not work with a Mysql database, we will still install it and have it ready to go for when you need it.
To install all the necessary packages, one command is all that is needed.
sudo pacman -S apache php php-apache mariadb mariadb-clients libmariadbclient
Once everything is installed, you can begin configuring the server
The main configuration for apache is in
/etc/httpd/conf/httpd.conf The file is rather sane be defualt and only a few things need to be enabled in order to allow PHP to run. Load up your favorite editor and make some chages:
AllowOverride All. Be sure that this is for the
/srv/http/ location only.
The next thing that needs to be addes is the PHP parts that allow apache to run PHP. Add the following in
/etc/http/conf/httpd.conf in their respective places.
LoadModule php7_module modules/libphp7.so AddHandler php7-script php Include conf/extra/php7_module.conf AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
You also need to uncomment the following line:
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
and comment the following line:
#LoadModule mpm_event_module modules/mod_mpm_event.so
Start the apache daemon
# systemctl start httpd
If you want to enable the daemon on boot,
# systemctl enable httpd
If all goes well you should be able to point your browser and get a directory listing of
/srv/http. The directory listing should be empty as we have not added anything there yet.
Most of the PHP configuration in
/etc/php/php.ini is fine as it is. There are a few modifications that need to be made in order to run Grav on your server. First it may be necessary to change the default upload size limit of 2MB.
upload_max_filesize = 10M
It is also recommended to enabled some of the extensions to satisfy some of the dependencies of common web applications. This can be done by removing the semicolon in front of the extension.
extension=curl.so extension=gd.so extension=iconv.so extension=intl.so extension=mysqli.so extension=pdo_mysql.so extension=xmlrpc.so extension=zip.so
You will want to restart the apache daemon
# systemctl restart httpd
By default, all website data is served out of
/srv/http/. This directory is owned by the user
http and the group
http. This can tend to cause some issues later as the root user or your personal user can either not write into the directory (user) or the stuff that is written is not accessible by apache (root). One of the easiest ways to remedy this issue is to allow your user to read, write, and execute anything out of that folder.
# setfacl -R -m user:<user>:rwx /srv/http/ Replacing
<user> with your personal user
Other options can include adding your user to the http group. Either way, make sure you can access that directory without changing the ownership of all the files to the root user.
Grav is extremely simple to install. They have 3 levels of installation files. They have the core system, the core+admin, and a skeleton package which contains a theme and a few useful bits already configured and ready to go out of the box. Installing is rather simple, all you really have to do is unzip the archive in your webroot. Since Grav does not require a database, nothing really needs to be configured out of the box. Pages will be served and you can modify the contents by modifying the corresponding files. It is recommended to install the admin center so that you can easily create and modify pages using the built in editor.
$ cd /srv/http/
$ bin/gpm install admin
If everything is installed and configured properly, you should be able to point your browser to the IP of your Odroid-c2 and be presented with your newly installed grav site.