This exercise is a part of [Linux servers (ICT4TN021, spring 2018) // Linux-palvelimet (ICT4TN021, kevät 2018)](http://www.haaga-helia.fi/fi/opinto-opas/opintojaksokuvaukset/ICT4TN021) school course organized as a part of Information Technology studies in Haaga-Helia university of Applied Sciences, Helsinki, Finland. Course lecturer [Tero Karvinen](http://terokarvinen.com/) has defined the original assignment descriptions in Finnish presented in this document in English. Answers and translations have been written by Pekka Helenius (me, ~ Fincer).
This exercise is a part of [Linux servers (ICT4TN021, spring 2018) // Linux-palvelimet (ICT4TN021, kevät 2018)](http://www.haaga-helia.fi/fi/opinto-opas/opintojaksokuvaukset/ICT4TN021) school course organized as a part of Information Technology studies in Haaga-Helia university of Applied Sciences, Helsinki, Finland. Course lecturer [Tero Karvinen](http://terokarvinen.com/) has defined the original assignment descriptions in Finnish presented in this document in English. Answers and translations have been written by Pekka Helenius (me, ~ Fincer).
*Table of contents:*
--------------
- [a) **Installation of HTTP server environment** Install Apache web server and set up a working web environment for each system user (http://example.com/~tero). Test the correct functionality with a sample website.](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#a-install-apache-web-server-and-set-up-a-working-web-environment-for-each-system-user-httpexamplecomtero-test-the-correct-functionality-with-a-sample-website)
- [b) **HTTP server logs** Browse and explore the websites on your local host. Find out any hints of successful (200 ok) website load events and failed load events (for instance, 404 not found). Analyse the relevant lines.](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#b-browse-and-explore-the-websites-on-your-local-host-find-out-any-hints-of-successful-200-ok-website-load-events-and-failed-load-events-for-instance-404-not-found-analyse-the-relevant-lines)
- [c) **HTTP server error event** Create a purposeful error in any code line which is executed by Apache web server (PHP or Python, for instance). Find out any relevant log lines and analyse them in detail.](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#c-create-a-purposeful-error-in-any-code-line-which-is-executed-by-apache-web-server-php-or-python-for-instance-find-out-any-relevant-log-lines-and-analyse-them-in-detail)
- [e) **Database management** Install and try out PhpMyAdmin or similar out-of-the-box web-based database management solution.](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#e-install-and-try-out-phpmyadmin-or-similar-out-of-the-box-web-based-database-management-solution)
- [f) **Web application** Create a web application which executes a simple calculation for the user (BMI calculator, for instance)](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#f-create-a-web-application-which-executes-a-simple-calculation-for-the-user-bmi-calculator-for-instance)
--------------
**a)** Install Apache web server and set up a working web environment for each system user (http://example.com/~tero). Test the correct functionality with a sample website.
**a)** Install Apache web server and set up a working web environment for each system user (http://example.com/~tero). Test the correct functionality with a sample website.
--------------
--------------
@ -328,15 +343,15 @@ Default syntax for Apache log files follow the layout which is described [here](
**Answer:**
**Answer:**
**NOTE!** We assume that the established Linux system has a working Apache HTTP daemon web server and PHP 5.0 or PHP 7.0 script language packages installed as Apache modules (see tasks a) and c) above).
**NOTE!** We assume that the established Linux system has a working Apache HTTP daemon web server and PHP 5.0 or PHP 7.0 script language packages installed as Apache modules (see tasks [a)](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#a-install-apache-web-server-and-set-up-a-working-web-environment-for-each-system-user-httpexamplecomtero-test-the-correct-functionality-with-a-sample-website) and [c)](https://github.com/Fincer/linux_server_setup/blob/master/exercises/h3.md#c-create-a-purposeful-error-in-any-code-line-which-is-executed-by-apache-web-server-php-or-python-for-instance-find-out-any-relevant-log-lines-and-analyse-them-in-detail) above).
1. [phpMyAdmin](https://en.wikipedia.org/wiki/PhpMyAdmin) requires MySQL/MariaDB database back-end server. Let's install MySQL database server with its runtime dependencies on Debian-based distribution (Ubuntu 16.04.3 LTS in this case).
**1.** [phpMyAdmin](https://en.wikipedia.org/wiki/PhpMyAdmin) requires MySQL/MariaDB database back-end server. Let's install MySQL database server with its runtime dependencies on Debian-based distribution (Ubuntu 16.04.3 LTS in this case).
```
```
sudo apt-get -y install mysql-server
sudo apt-get -y install mysql-server
```
```
2. Local administrator (assumed to belong to sudo group) is asked to set a new password for root MySQL database root account:
**2.** Local administrator (assumed to belong to sudo group) is asked to set a new password for root MySQL database root account:
**NOTE!** This description applies to Ubuntu 16.04 LTS. Newer OS releases may not ask you to set MySQL password after MySQL server installation. If you don't see a blue screen stating "While not mandatory...", run the following command instead:
**NOTE!** This description applies to Ubuntu 16.04 LTS. Newer OS releases may not ask you to set MySQL password after MySQL server installation. If you don't see a blue screen stating "While not mandatory...", run the following command instead:
@ -360,7 +375,7 @@ We should choose a strong password (`Hu8aS1n?tI23` or `Tu$pAR!iMu65` etc. Can be
When you have entered your password, press `TAB` and then press `<Ok>` (or just `ENTER` key). Type the password again and continue.
When you have entered your password, press `TAB` and then press `<Ok>` (or just `ENTER` key). Type the password again and continue.
3. Let's install [phpMyAdmin](https://en.wikipedia.org/wiki/PhpMyAdmin) with its runtime dependencies on Debian-based distribution (Ubuntu 16.04.3 LTS in this case).
**3.** Let's install [phpMyAdmin](https://en.wikipedia.org/wiki/PhpMyAdmin) with its runtime dependencies on Debian-based distribution (Ubuntu 16.04.3 LTS in this case).
4. On Debian-based systems, the next screen states:
**4.** On Debian-based systems, the next screen states:
```
```
Configuring phpmyadmin
Configuring phpmyadmin
@ -383,7 +398,7 @@ Web server to reconfigure automatically:
Because we assume that you have Apache2 and not lighttpd, we should select `apache2`. Press `SPACE` key so that option `apache2` will have asterix in the brackets (`[*]`). After that, press `TAB` key to move your current selection to `<Ok>` and press `ENTER` key.
Because we assume that you have Apache2 and not lighttpd, we should select `apache2`. Press `SPACE` key so that option `apache2` will have asterix in the brackets (`[*]`). After that, press `TAB` key to move your current selection to `<Ok>` and press `ENTER` key.
5. The next screen states:
**5.** The next screen states:
```
```
Configuring phpmyadmin
Configuring phpmyadmin
@ -410,7 +425,7 @@ Let's choose option `<Yes>` because we don't have earlier database in our system
**NOTE!** dpkg tool `dpkg-reconfigure` makes it possible to change package-related configuration in Debian-based systems afterwards (for instance, `sudo dpkg-reconfigure phpmyadmin`). However, pay special attention and use extra care if you do any configurations afterwards.
**NOTE!** dpkg tool `dpkg-reconfigure` makes it possible to change package-related configuration in Debian-based systems afterwards (for instance, `sudo dpkg-reconfigure phpmyadmin`). However, pay special attention and use extra care if you do any configurations afterwards.
6. The next screen asks system administrator to set up MySQL database-related password for phpmyadmin MySQL user:
**6.** The next screen asks system administrator to set up MySQL database-related password for phpmyadmin MySQL user:
```
```
Configuring phpmyadmin
Configuring phpmyadmin
@ -422,9 +437,9 @@ MySQL application password for phpmyadmin:
Let's pick up a strong password for phpmyadmin. Take a look on step 2. for setting up a strong password. Use different password here.
Let's pick up a strong password for phpmyadmin. Take a look on step 2. for setting up a strong password. Use different password here.
7. If you are not asked to set up a default phpmyadmin username or password, please run `sudo dpkg-reconfigure phpmyadmin`. The default phpmyadmin username is usually `phpmyadmin` and the login password is the one you write down by executing the command mentioned earlier in this step.
**7.** If you are not asked to set up a default phpmyadmin username or password, please run `sudo dpkg-reconfigure phpmyadmin`. The default phpmyadmin username is usually `phpmyadmin` and the login password is the one you write down by executing the command mentioned earlier in this step.
8. Let's try accessing phpMyAdmin front page:
**8.** Let's try accessing phpMyAdmin front page:
```
```
xdg-open http://localhost/phpmyadmin
xdg-open http://localhost/phpmyadmin
@ -434,13 +449,13 @@ If the installation has been successful, the web browser view should look like t
**NOTE!** We assume that the Linux installation has a working Apache HTTP daemon web server with correct PHP support enabled. Apache server has `userdir` module enabled, and some local user has `public_html` folder created in `$HOME` folder.
**NOTE!** We assume that the Linux installation has a working Apache HTTP daemon web server with correct PHP support enabled. Apache server has `userdir` module enabled, and some local user has `public_html` folder created in `$HOME` folder.
1. Let's create the following, very simple PHP code and save it to `~/public_html/rainfall.php` (current user)
**1.** Let's create the following, very simple PHP code and save it to `~/public_html/rainfall.php` (current user)