Web Applications as Easy as Pie

Dr. Andres Baravalle

Intro

What we are going to do today is a taster activity based on what you will be doing in your second year at the University of East London.

Do not be worried if you do not understand all the steps - it is normal at this stage.

Installing your system

We will be installing Pidora on your Rasperri Pies. Pidora is a Linux distribution based on Fedora Linux.

We are going to install Pidora using Noobs 1.3.x.

The installation of the operating system will take about 12 minutes.

Steps

During the installation, you will:

  1. Select a UK keyboard
  2. Set up the ntpd daemon, to sync time
  3. Create a superuser (root) and a unprivileged account
  4. Set the swap file size to 256 mb
  5. Set up the environment at boot time (text or graphical; please choose text). This is very important as the monitor does not support the default video settings. If you get this step wrong you will have to start again!
  6. Set video settings: HDMI with “overscan” and tick the box “DVI Adapter?”

If anything goes wrong during the installation, you’ll probably need to get your SD card reformatted and to start the installation again.

First boot

After your first boot, you will see the log in screen.

Log in with your user account, and run the following command:

id addr

The command will return an output including your ip address. It is likely to be 192.168.1.x. Take note of your ip address.

Linux command line: working with directories

Change directory

cd foldername
cd .. (goes back one level)
cd / (goes to the root)

Coping resources

cp source destination

Moving or renaming resources

mv source destination

Creating folders

mkdir folder

Changing owner

chmod

Show current folder

pwd

Linux command line: other commands

Show text file

cat filename

Documentation

man command

Change to superuser

su -

Find the ip address

ifconfig eth0

Free space

df -h

Using the root account

We will now use the super user:

su -

Updating your system (not for the Open Day)

Once the system is installed, you should update it (do not do it on the Open Day as it’s a lengthy process).

yum update -y --nogpgcheck

Installing the environment

We are now ready to complete the installation of our LAMP stack:

yum install httpd php php-mysqli mysql mysql-server wordpress -y

Enabling the web and database servers at startup

/bin/systemctl enable httpd.service
/bin/systemctl enable mariadb.service

Graphical mode

We can now boot into graphical mode:

init 5

Once in graphical mode, we will have to open a terminal to run the remaining commands.

Start the database server

/bin/systemctl start mariadb.service  

Setting up the database

Before we move on, we need to create a superuser for the database:

/usr/bin/mysqladmin -u root password 'new-password'
              

Now we are ready to log-in into the database server to set it up properly. We need to log in to the mysql shell:
mysql -u root -p         

We can now create a user and a database for our application and exit the shell (if there are no errors):

CREATE DATABASE wordpress;
CREATE USER wordpress@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* to wordpress@localhost;
FLUSH PRIVILEGES;
exit 

Setting up the web server

We will need to edit the file /etc/php.ini  (your PHP settings):

leafpad /etc/php.ini

change the following lines:

max_execution_time = 300
memory_limit = 256M  

and update the database settings in the Wordpress configuration file:

leafpad /etc/wordpress/wp-config.php       

Set the details for the database, the database username and the password, and save the file.

Starting the web server

Now we are ready to start the web server:

/bin/systemctl start httpd.service 

Open the test page for the web server with the default browser: http://localhost to verify that the server is up and running.

Installing Wordpress

Before starting the Wordpress installation we need to edit the settings file: /etc/wordpress/wp-config.php (using leafpad) and include the details for the database, the database username and the password.

Once you have saved your wp-config.php files, open your browser at http://localhost/wordpress  and start the installation.

If things go wrong...

If things go wrong during the Wordpress installation, you will have to roll back and restart the installation.

The easier way to roll back is to drop the database, delete the settings file and start again.

To drop the database, connect to mysql as root and run the command:


DROP DATABASE wordpress;

And then create the database again and reset the privileges.

Finally!

You are ready to create your first blog post – and you can check the web sites of the other persons working on this activity, if you know their IP address!

This work

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License (what does it mean? you can copy/modify/redistribute this content).

Creative Commons License