Kako podesiti LAMP server na Debian 9

Milan Leon
Mar 19, 2018 · 8 min read

Instalacija LAMP servera

$ sudo apt-get update
$ sudo apt-get install apache2 php libapache2-mod-php mysql-client mysql-server phpmyadmin
Selektujte apache2 kliknom na SPACE, zatim klik na TAB, pa ENTER
Kliknite na YES
Unesite vašu novu lozinku, a u nastavku je potvrdite
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
Active: active (running) since Sun 2018-03-13 02:36:48 UTC; 5min ago
Main PID: 14463 (apache2)
CGroup: /system.slice/apache2.service
├─14463 /usr/sbin/apache2 -k start
├─14465 /usr/sbin/apache2 -k start
└─14466 /usr/sbin/apache2 -k start
$ sudo systmectl status mysql
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-03-13 03:05:17 UTC; 1min 37s ago
Main PID: 16127 (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─16127 /usr/sbin/mysqld
$ sudo mysql_secure_installation
- Remove anonymous users? [Y/n] y- Disallow root login remotely? [Y/n] y- Remove test database and access to it? [Y/n] y- Reload privilege tables now? [Y/n] y
index strana nakon instalcije na Debian 9
http://localhost/phpmyadmin
Unestite korisničko ime phpmyadmin i lozinku koju ste kreirali prilikom instalacije

Login na MySQL server i kreiranje korisnika

$ sudo mysql -u root -p
$ MariaDB [(none)]> create user 'test'@'localhost' identified by 'unisite_vasu_lozinku';
$ MariaDB [(none)]> grant all privileges on *.* to 'test’@’localhost’ ;$ MariaDB [(none)]> flush privileges;
http://localhost/phpmyadmin
Nova kreirana baza novog korisnika

Kreiranje direktorijuma za vaš novi sajt

sudo mkdir -p /var/www/html/primer.com/public_html
sudo mkdir -p /var/www/html/primer.com/log
sudo mkdir -p /var/www/html/primer.com//backups
$ sudo chown -R $USER:$USER /var/www/html/primer.com/public_html
$ sudo chmod -R 755 /var/www/html/primer.com/public_html

Kreiranje novog Virtuelnog host fajla

$ nano /etc/apache2/sites-available/000-default.conf
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/primer.com.conf
$ sudo nano /etc/apache2/sites-available/primer.com.conf
# domain: primer.com
# public: /var/www/html/primer.com/public_html/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin@primer.com
ServerName primer.com
ServerAlias www.primer.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/primer.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/primer.com/log/error.log
CustomLog /var/www/html/primer.com/log/access.log combined
</VirtualHost>

Omogućavanje rada virtuelnog host fajla

$ sudo a2ensite primer.com.conf
Output
Enabling site primer.com.
To activate the new configuration, you need to run:
service apache2 reload
$ sudo systemctl restart apache2

Onemogućavanje rada hosting fajla koji je po defaultu.

$ sudo a2dissite 000-default.conf
$ sudo systemctl restart apache2

Bravo. Završili ste podešavanje.

Postavljanje hostname na lokalni računar i testiranje

$ nano /etc/hostname
127.0.0.1 localhost

111.111.111.111 primer.com

“Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.”

$ chown -R www-data:www-data /var/www/html/primer.com/public_html
$ ls -lart /var/www

Milan Leon

Written by

Cyber Security Specialist || Coding || #python #developer #infosec #pentester

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade