Pełna instalacja serwera LAMP Linux, Apache, MySql, PHP Debian 9
Ten poradnik opisuje jak kompleksowo zainstalować serwer LAMP czyli podstawowe usługi Apache, MySql, PHP oraz phpmyadmin.
Prok po kroku dokonamy instalacji wszystkich pakietów.
Zaczynamy od ustawienia poprawnego hostname serwera:
1 | nano/etc/hosts |
I edytujemy
1 2 3 4 5 6 7 | 127.0.0.1 localhost.localdomain localhost 94.130.246.172 node.serwerweb.pl node # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback ff02::1ip6-allnodes ff02::2ip6-allrouters |
Interesuje nas ta pogrubiona linijka.
Adresu IP nie ruszamy dokonujemy jedynie zmiany hostname jakim będzie widoczny nasz serwer.
Edytujemy również plik:
1 | nano/etc/hostname |
I zmieniamy na
1 | node.serwerweb.pl |
W celu zmian w całym systemie restartujemy serwer poleceniem:
1 2 | reboot |
sprawdzamy poprawność ustawionego hostname:
1 2 | hostname hostname-f |
Obydwa polecenia powinny nam zwrócić tą sąmą wartość:
node.serwerweb.pl
1 2 3 4 | root@node:/tmp# hostname node.serwerweb.pl root@node:/tmp# hostname -f node.serwerweb.pl |
Następnie wykonujemy aktualizację systemu:
1 2 | apt-get update apt-get upgrade |
Instalujemy silnik baz danych mariadb
MariaDB:
1 | apt-get-yinstall mariadb-server mariadb-client |
Re-konfigurujemy serwer mysql w następujący sposób wydając polecenie:
mysql_secure_installation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | mysql_secure_installation NOTE:RUNNING ALL PARTS OF THISSCRIPT ISRECOMMENDED FORALL MariaDB SERVERS INPRODUCTION USE!PLEASE READ EACHSTEP CAREFULLY! Inorder tolog into MariaDB tosecure it,we'll need the current password for the root user. If you've just installed MariaDB,and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): <-- Hit return OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] -- y New password: <-- Enter the new password for the MariaDB root user Re-enter new password: <-- Enter the password again Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] -- y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] -- y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] -- y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] -- y ... Success! Cleaning up... All done! If you've completed all of the above steps,your MariaDB installation should now be secure. Thanks forusing MariaDB! |
Instalujemy serwer Apache:
1 | apt-get-yinstall apache2 |
Instalacja PHP:
1 | apt-get-yinstall php7.0libapache2-mod-php7.0 |
Restartujemy serwer Apache w celu zapisania zmian:
1 | service apache2 restart |
Instalujemy niezbędne rozszerzenia php:
1 | apt-cache search php7.0 |
1 | apt-get-yinstall php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl |
Ponownie wykonujemy restart serwera apache w celu zapisania zmian:
1 | service apache2 restart |
Instalacja cache dla serwera www:
1 2 | apt-get-yinstall php7.0-opcache apt-get-yinstall php-apcu |
Zapisujemy zmiany:
1 | service apache2 restart |
Ostatnim krokiem jest instalacja PHPMYADMIN fraficzny interfejs zarządzania bazami danych napisany w php.
1 | apt-get-yinstall phpmyadmin |
I odpowiadamy na pytania w instalatorze:
1 2 3 4 5 | Web server toreconfigure automatically:<--apache2 Configure database forphpmyadmin with dbconfig-common?<--Yes Password of the database'sadministrative user:<--Podajemy wcześciej ustalone hasłoprzy instalacji mysql/mariadb MySQL application password forphpmyadmin:<--Ponownie podajemy hasłoustalone wcześniej |
PhpMyAdmin dostępny jest pod adresem:
1 | http://ADRESIPSERWERA/phpmyadmin/ |
Ostatni krok to uruchomienie możliwości logowania użytkownika root do phpmyadmin:
wydajemy polecenie:
1 | echo"UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';FLUSH PRIVILEGES;"|mysql-uroot-p |
Wpisujemy hasło root i to wszystko 🙂
To wszystko mamy w pełni działający serwer www z mysql 😉
Jak zaktualizować apache w debianie 9? Server version: Apache/2.4.25 (Debian) i to jest niby najnowsze, a dopiero od wersji 2.4.26 jest obsługa http2
Hej,
Najprościej będzie zmieniając repo na te z wersji testing:
Haszujesz repozytoria debian 9 i wlpejasz te wyżej testinga.
Zaktualizuje ci pakiety do nowszych.
No i odpalasz moduł: