Skip to main content

Warming up with LAMP

My studies with Linux continue and our first assignment was executing an old exam from the basic course (Työasemat ja tietoverkot, Linux).

I chose this exam from beginning of spring in 2012. http://terokarvinen.com/2012/linux-koe-tyoasemat-ja-tietoverkot-25
This exercise was made by using Xubuntu's 14.04 version.

Installing Apache


sudo apt-get update
First things first. I wanted to have the latest packages available.
sudo apt-get install apache2
I changed the location to user's directory and restarted Apache.

After the installation I tested if Apache is running by writing localhost to the web browser's address bar. "It works!" -page appeared.


Installing MySql


sudo apt-get install mysql-server
After a moment the console asked me to define root's new password. I did this and continued the installation.

sudo apt-get install phpmyadmin
Now when I had mySql I could connect it with phpmyadmin. In package configuration I selected Apache2. 

The installation was successful and phpMyAdmin appeared to localhost/phpmyadmin.



Installing PHP


sudo apt-get install libapache2-mod-php5
I ran the installation command for PHP module and navigated to /apache2/mods-enabled. I would need to modify a file called php5.conf in order to get the module actually working.

sudoedit php5.conf
I commented the whole Running PHP scripts in user directories is disabled by default with ### and saved the file.



php5.conf after being modified

Installation and management of SSH


sudo apt-get install openssh-server

After the installation was complete I created accounts for Einari Vähäkäähkä, Pekka Winha, Åke Andersson ja Leila Laila. 

sudo adduser einavaha
sudo adduser pekkwinh
sudo adduser akeande 
sudo adduser leillail

Each command was followed by information form where I entered the user's full name and password.

Creating a webpage and testing PHP

ssh leillail@localhost
mkdir public_html
nano index.html

I logged into Leila's profile, made a new folder for the webpage and created there index.html
I wrote a small sample code for her page and it appeared in localhost/~leillail.




I still needed to test if the PHP module was working so I signed out from Leila's profile and got in this time as Pekka Winha. Once again I made a new directory public_html but this time instead of html I created a simple php file. 

And it worked! localhost/~pekkawinh/foo.php showed up as it should. 

Creating a Shell Script



The final goal was creating a shell script that could show the free disc space and IP.


nano mystatus.sh
First I created the file. Notice that .sh wouldn't be required but it is just something I have used to do to clarify things. The script would work perfectly fine without it too. 

I wrote the needed commands ( df -h and /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2) inside the file and saved it.

chmod +x mystatus.sh
I gave the rights for all users being able executing this command.

sudo cp mystatus.sh/usr/local/bin
The last step was to copy the script into this location so it would be able to run.



Sources: Lectures by Tero Karvinen,  https://scottlinux.com/2013/04/30/centos-linux-or-ubuntu-linux-get-list-of-ip-addresses-on-server/

Based on Linux course by Tero Karvinen (http://terokarvinen.com)

Comments

Popular posts from this blog

Building Love-O-Meter by using a temperature sensor

This "Love-O-Meter" is based on the tutorial by Arduino and it comes with the starter kit. It uses a temperature sensor to measure the warmth of your skin and then starts to turn on (or off) the LEDs  indicated by the temperature.

The components Arduino UNOBreadboardJumper wiresLEDs220 ohm resistorsTMP36 temperature sensor

Building the Circuit
At first I ran the "Hello World" for Arduino to make sure the environment would work as expected. Now I could start to connect the jumper wires between Arduino UNO and the breadboard.

As usually I connected the breadboard to power (5V) and to the ground (GND). I inserted the TMP36 on the breadboard so the rounded part of the sensor would face away from Arduino.

I attached 3 LED lights and the resistors and connected them with Arduino. The lights should react to the heat of the finger and if the temperature would get hot enough all the lights would be on and would also tell you if you are a hot lover or not...

The result and the …

Creating a Bootable USB for Kali Linux

If you are interested to see my documentation about making a bootable USB for Xubuntu please click here!

This USB was made by using the latest version of Xubuntu (the 14.04 release).

Downloading Kali Linux 
23.13. After navigating to https://www.kali.org/ I chose the version that would suit me the best and started downloading the ISO image for 64-Bit system.


USB imaging
22.40. I followed the guide offered by kali.org and used the commandsudo fdisk -lwithout plugging the USB yet. I needed to pay attention to the path of Device Boot (/dev/sdb1). After this I inserted USB and ran the same command again. Now I could see how the name of Device Boot had changed to sdc1. This would be my USB to use.

22.50 It only took a while to format the dd code correctly as the base was already given on Kali's web page. After running the correct command for the first time I got an error message "'/dev/sdc1': Permission denied". In these kind of situations I tend to ask sudo for help an…

Using a button to control the LED light

This time my project was to configure how to build a button that would turn on and off depending if the user is pushing it or not. While holding the button down the LED should stay on until removing the finger.



For this assignment I used the fallowing components:
Arduino UNO and USBJumper wiresLED lightBreadboardButton10k ohm resistor
At first I run the "Hello World" for Arduino and made sure that the LED I was using worked properly (read my previous post).

I attached the button in the middle of the breadboard so the legs were touching the both "sides" of it.


Now I started to connect the jumper wires between the Arduino UNO and the breadboard. In order to get it working like in the sample code (Ardoino > Examples > 02.Digital > Button)
I linked the wires with Arduino's 5V (red wire, positive) and ground (black wire, negative) to the equal holes on the very corner of the breadboard (+ and -). I put the white jumper wire to connect the positive circuit to t…