LAMP

Aloitin tehtävän teon 20:37 maanantai iltana. Ensimmäiseksi asensin Apachen uudelleen:

sudo apt-get install apache2

Tämän jälkeen testasin sen toimivuuden:Screenshot from 2017-02-13 20-39-18.png

Apache toimii, seuraavaksi php:

sudo apt-get install libapache2-mod-php php7.0

sudo a2enmod userdir

cd /etc/apache2

ls

cd mods-available/

sudoedit php7.0.conf //tämä siis, jotta php toimii kotikansiossa

service apache2 restart

Kello oli tässä vaiheessa 20:51

Sen testaaminen:

cd; mkdir public_html

cd public_html

juuso@juuso-p6-2020sc:~/public_html$ curl localhost/~juuso/; echo
4

PHP toimii, tässä vaiheessa 21:05

Seuraavaksi MySQL

sudo apt-get install php-mysql mysql-server mysql-client

Tässä vaiheessa luodaan myös turvallinen salasana MySQL:lle. Sitten testataan:

juuso@juuso-p6-2020sc:~/public_html$ mysql
ERROR 1045 (28000): Access denied for user ‘juuso’@’localhost’ (using password: NO)
juuso@juuso-p6-2020sc:~/public_html$ mysql -up
ERROR 1045 (28000): Access denied for user ‘p’@’localhost’ (using password: NO)
juuso@juuso-p6-2020sc:~/public_html$ mysql -uroot –password

mysql> CREATE DATABASE arachnids CHARACTER SET utf8;
Query OK, 1 row affected (0,00 sec)

mysql> SHOW DATABASES;
+——————–+
| Database |
+——————–+
| information_schema |
| arachnids |
| mysql |
| performance_schema |
| sys |
+——————–+
5 rows in set (0,01 sec)

mysql> GRANT ALL ON arachnids.* TO arachnids@localhost IDENTIFIED BY ‘adfs93245ng’;
Query OK, 0 rows affected, 1 warning (0,00 sec)

mysql> exit

juuso@juuso-p6-2020sc:~$ mysql -uarachnids -p

mysql> CREATE DATABASE test;
ERROR 1044 (42000): Access denied for user ‘arachnids’@’localhost’ to database ‘test’
mysql> USE student;
ERROR 1044 (42000): Access denied for user ‘arachnids’@’localhost’ to database ‘student’
mysql> USE arachnids;
Database changed
mysql> CREATE TABLE arachnids (id INT AUTO_INCREMENT PRIMARY KEY, name varchar(1024));
Query OK, 0 rows affected (0,19 sec)

mysql> DESCRIBE arachnids;
+——-+—————+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+——-+—————+——+—–+———+—————-+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(1024) | YES | | NULL | |
+——-+—————+——+—–+———+—————-+
2 rows in set (0,01 sec)

mysql> INSERT INTO arachnids(name) VALUES (“hämähäkki”);
Query OK, 1 row affected (0,02 sec)

mysql> SHOW DATABASES;
+——————–+
| Database |
+——————–+
| information_schema |
| arachnids |
+——————–+
2 rows in set (0,00 sec)

mysql> SELECT * FROM arachnids;
+—-+————–+
| id | name |
+—-+————–+
| 1 | hämähäkki |
+—-+————–+
1 row in set (0,00 sec)

mysql> UPDATE arachnids SET name=”spider” WHERE name=”hämähäkki”;
Query OK, 1 row affected (0,02 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> SELECT * FROM arachnids;
+—-+——–+
| id | name |
+—-+——–+
| 1 | spider |
+—-+——–+
1 row in set (0,01 sec)

mysql> DELETE FROM arachnids WHERE name=”spider”;
Query OK, 1 row affected (0,03 sec)

mysql> SELECT * FROM arachnids;
Empty set (0,00 sec)

mysql>

Täten voitiin todeta, että myös MySQL toimii, ja kaikki LAMPin komponentit on kasassa. Tässä vaiheessa kello oli 21:30.

Ja tässä log.txt: http://pastebin.com/BtdjuV19

Advertisements

Apache2

Aloitin tehtävän tekemisen noin 21:12 tehtävässä 1 mainitulla koneella käytössäni olevalla Lubuntu 16.10.

sudo apt-get update ; sudo apt-get install apache2 ; man apache2.

Terminaaliloki:

juuso@juuso-p6-2020sc:~$ apache2ctl
Usage: /usr/sbin/apache2ctl start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus|help
/usr/sbin/apache2ctl
/usr/sbin/apache2ctl -h            (for help on )
juuso@juuso-p6-2020sc:~$ apache2ctl configtest
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
Syntax OK
juuso@juuso-p6-2020sc:~$ apache2ctl start
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action ‘start’ failed.
The Apache error log may have more information.
juuso@juuso-p6-2020sc:~$ sudo apache2ctl start
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
httpd (pid 3730) already running
juuso@juuso-p6-2020sc:~$ apache2 stop
Usage: apache2 [-D name] [-d directory] [-f file]
[-C “directive”] [-c “directive”]
[-k start|restart|graceful|graceful-stop|stop]
[-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
-D name            : define a name for use in directives
-d directory       : specify an alternate initial ServerRoot
-f file            : specify an alternate ServerConfigFile
-C “directive”     : process directive before reading config files
-c “directive”     : process directive after reading config files
-e level           : show startup errors of level (see LogLevel)
-E file            : log startup errors to file
-v                 : show version number
-V                 : show compile settings
-h                 : list available command line options (this page)
-l                 : list compiled in modules
-L                 : list available configuration directives
-t -D DUMP_VHOSTS  : show parsed vhost settings
-t -D DUMP_RUN_CFG : show parsed run settings
-S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
-t -D DUMP_MODULES : show all loaded modules
-M                 : a synonym for -t -D DUMP_MODULES
-t                 : run syntax check for config files
-T                 : start without DocumentRoot(s) check
-X                 : debug mode (only one worker, do not detach)
juuso@juuso-p6-2020sc:~$ apache2ctl stop
AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
httpd (pid 3730?) not running

screenshot-from-2017-02-07-21-29-05

 

Loki: 127.0.0.1 – – [07/Feb/2017:21:27:12 +0200] “GET / HTTP/1.1” 200 3525 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:45.9) Gecko/20100101 Goanna/3.0 Firefox/45.9 PaleMoon/27.0.3”