уторак, 19. мај 2015.

Šta je LAMP i kako se instalira i konfiguriše u Fedor-i?

LAMP je akronim za skup paketa slobodnog software-a otvorenog koda koji se odnosi na prva slova. L kao Linux operativni sistem, A kao Apache web server, M kao MySQL višekorisnički sistem za upravljanje bazama podataka ili MariaDB; i P kao PHP programski jezik, mada sve češće i Perl ili Python. Postoje i drugi slični akronimi ali ja ću se ovde ograditi na Linux, Fedora distribuciju, KDE okruženje; Apache serverPHP programski jezik. Naravno da se ApacheMySQL i PHP mogu instalirati na Windows platformu; često je to slučaj u školama računara; instalacija na Windows platformi je nešto jednostavnija pod uslovom da se bar malo razumete u Windows administraciju; mada ja smatram da je LAMP-u prirodno okruženje u Linux-u.


( LAMP - paket slobodnog software-a )

Zašto bi neko instalirao LAMP?

U poslovnom svetu LAMP predstavlja besplatno ili izuzetno jeftino poslovno rešenje i najćešće ga implementiraju firme koje imaju potrebu za server-om, web sajtovima i bazama podataka. Skoro sav hosting u Srbiji je uglavnom baziran na Apache i MySQL i za većinu kompanija takva implementacija može uštedeti ogromna materijalna sredstva. Individualna implementacija je odlična za svakog ko želi da uči web programiranje, baze podataka ili da se profesionalno bavi Internet poslovanjem i izradom web sajtova.


Kako se LAMP instalira i konfiguriše u Fedor-i?

Za razliku od Ubunt-aLinux distribucije koja prilikom instalacije ne kreira root password već samo korisnički password, u Fedora-i pređite na root direktorijum root autentifikacijom; komandom su u Terminal-u.

[hacker@localhost ~]$ su
Password:
[root@localhost hacker]#


Prvo ćemo onemogućiti SELinux - Linux Kernel Security Module, tako što ćemo u njegovom konfiguracionom file-u podesiti SELINUX na disabled, da nam nebi zaustavljao server. Ja koristim iz navike VI tekstualni editor dok vi možete neki drugi ako vam je lakše.

[root@localhost hacker]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@localhost hacker]#


Sad morate resetovati operativni sistem da bi ovo imalo efekta. Idite na Leave - Restart i ponovo se vratite na root direktorijum. Pokrenite instalaciju u kodu navedenih paketa.

[root@localhost hacker]# dnf install httpd php php-gd mysql-server phpAdmin

Nemojte se uznemiravati ako vam se nije instalirao MySQL. Otvorite Software Management, zatim kliknite na ikonicu Internet i u polje za pretraživanje paketa otkucajte mysql. Potvrdite instalaciju svih 10 paketa koji počinju sa community-mysql i kliknite Apply.


( Fedora, KDE, Software Management )

Posle instaliranja neophodno je da prvo testiramo Apache server.

[root@localhost hacker]# service httpd start
Redirecting to /bin/systemctl start httpd.service
[root@localhost hacker]#


Otvorite Internet Browser koji vi koristite i ukucajte localhost. Ukoliko ste dobili ovakvu stranicu kao na slici, znači da ste uspeli.


( Test Apache web server-a )

Sledeći korak je da podesimo MySQL. Posle sledeće ukucane komande u Terminal-u tražiće vam se password, pošto prvi put pokrećete MySQL klijent; podrazumeva se da vam je MySQL password ništa ili vaš root password, zato samo pritisnite Enter na tastaturi.

[root@localhost hacker]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


Zatim ćemo da set-ujemo password. Možete da ga nazovete kako hoćete. Ovde ćemo ga nazvati npr. world.

mysql> set password = password('world');
Query OK, 0 rows affected (0.05 sec)


Izađite iz MySQL-a, jednostavno otkucajte exit i pritisnite Enter.

mysql> exit
Bye
[root@localhost hacker]#

Zatim setujemo naš MySQL password i u phpMyAdmin konfiguracionom file-u.

[root@localhost hacker]# vi /etc/phpMyAdmin/config.inc.php

<?php
/**
* phpMyAdmin configuration file, you can use it as base for the manual
* configuration. For easier setup you can use "setup/".
*
* All directives are explained in Documentation.html and on phpMyAdmin
* wiki <http://wiki.phpmyadmin.net>.
*/

/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = '117651762425567775'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/**
* Server(s) configuration
*/
$i = 0;

// The $cfg['Servers'] array starts with $cfg['Servers'][1]. Do not use
// $cfg['Servers'][0]. You can disable a server config entry by setting host
// to ''. If you want more than one server, just copy following section
// (including $i incrementation) serveral times. There is no need to define
// full server array, just define values you need to change.
$i++;
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'mysqli'; // The php MySQL extension to use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress'] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings
// (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user"
// and "mysql/db" tables).
// The controluser is also
// used for all relational
// features (pmadb)
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'world'; // MySQL password (only needed
// with 'config' auth_type)

$cfg['Servers'][$i]['only_db'] = ''; // If set to a db-name, only
// this db is displayed in left frame
// It may also be an array of db-names, where sorting orde
r is relevant.
$cfg['Servers'][$i]['hide_db'] = ''; // Database name to be hidden from listings
$cfg['Servers'][$i]['verbose'] = ''; // Verbose name for this host - leave blank to show the ho
stname

$cfg['Servers'][$i]['pmadb'] = ''; // Database used for Relation, Bookmark and PDF Features
// (see scripts/create_tables.sql)
// - leave blank for no support
// DEFAULT: 'phpmyadmin'
$cfg['Servers'][$i]['bookmarktable'] = ''; // Bookmark table
// - leave blank for no bookmark support
// DEFAULT: 'pma_bookmark'
$cfg['Servers'][$i]['relation'] = ''; // table to describe the relation between links (see doc)
// - leave blank for no relation-links support
// DEFAULT: 'pma_relation'
$cfg['Servers'][$i]['table_info'] = ''; // table to describe the display fields
// - leave blank for no display fields support
// DEFAULT: 'pma_table_info'
$cfg['Servers'][$i]['table_coords'] = ''; // table to describe the tables position for the PDF schem
a
// - leave blank for no PDF schema support
// DEFAULT: 'pma_table_coords'
$cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages of relationpdf
// - leave blank if you don't want to use this
// DEFAULT: 'pma_pdf_pages'
$cfg['Servers'][$i]['column_info'] = ''; // table to store column information
// - leave blank for no column comments/mime types
// DEFAULT: 'pma_column_info'
$cfg['Servers'][$i]['history'] = ''; // table to store SQL history
// - leave blank for no SQL query history
// DEFAULT: 'pma_history'
$cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your pma_* tables
// are up to date. This prevents compatibility
// checks and thereby increases performance.
$cfg['Servers'][$i]['AllowRoot'] = TRUE; // whether to allow root login
$cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use
= '';
$cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults
= array();
$cfg['Servers'][$i]['AllowNoPassword'] // Allow logins without a password. Do not change the FALS
E
= FALSE; // default unless you're running a passwordless MySQL serv
er
$cfg['Servers'][$i]['designer_coords'] // Leave blank (default) for no Designer support, otherwis
e
= ''; // set to suggested 'pma_designer_coords' if really needed
$cfg['Servers'][$i]['bs_garbage_threshold'] // Blobstreaming: Recommented default value from upstream
= 50; // DEFAULT: '50'
$cfg['Servers'][$i]['bs_repository_threshold'] // Blobstreaming: Recommented default value from upstream
= '32M'; // DEFAULT: '32M'
$cfg['Servers'][$i]['bs_temp_blob_timeout'] // Blobstreaming: Recommented default value from upstream
= 600; // DEFAULT: '600'
$cfg['Servers'][$i]['bs_temp_log_threshold'] // Blobstreaming: Recommented default value from upstream
= '32M'; // DEFAULT: '32M'
/*
* End of servers configuration
*/

/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '/var/lib/phpMyAdmin/upload';
$cfg['SaveDir'] = '/var/lib/phpMyAdmin/save';

/*
* Disable the default warning that is displayed on the DB Details Structure
* page if any of the required Tables for the relation features is not found
*/
$cfg['PmaNoRelation_DisableWarning'] = TRUE;
?>


Ukoliko ste ovo sve uspešno odradili, nastavljamo sa testiranjem. Ukucajte:

[root@localhost html]# cd /var/www/html

Kreirajmo jednu PHP stranicu, neka se zove info.

[root@localhost html]# vi info.php

Pređite u --insert mode-- i zatim otkucajte:

<?php
phpinfo();
?>
To je sav PHP kod. Snimite ga i izađite iz VI - tekst editor-a.
Resetujte Apache server.

[root@localhost html]# service httpd restart
Redirecting to /bin/systemctl restart httpd.service
[root@localhost html]#


Otvorite vaš Internet Browser, i otkucajte localhost/info.php. Ukoliko ste dobili prikaz kao na slici, ponovo ste sve uspeli. 


( Testiranje Apache Servera, putem info php stranice)


Ostalo nam je još samo da proverimo pokretanje server-a kroz runlevels chkconfig utility:

[root@localhost hacker]# chkconfig --levels 235 httpd on
Note: Forwarding request to 'systemctl enable httpd.service'.
[root@localhost hacker]# chkconfig --levels 235 mysqld on
Note: Forwarding request to 'systemctl enable mysqld.service'.
[root@localhost hacker]#


Izađite iz root autentifikacije i probajte pokrenuti MySQL.

[root@localhost hacker]# exit
exit
[hacker@localhost ~]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[hacker@localhost ~]$


Ukoliko je i kod vas sve ovako prošlo jednostavno, spremni ste za rad. Čestitam!