Apache2 mysql php phpmyadmin linux

Быстрая установка Apache, PHP, MySQL и phpMyAdmin на Ubuntu

Привет, читатель! В данной статье пойдёт речь о безболезненной установке и первичной настройки LAMP на Ubuntu. Цель данного поста — дать возможность новичку быстро, без трудностей и заморочек подготовить систему Ubuntu для начала обучения веб разработки. Рекомендую использовать эту статью только в начале обучения, так как, если вы хотите быть профи, придется изучить всё аспекты технологии LAMP детально.

Что это

Откуда взялось слово LAMP, спросите вы. Хоть как бы забавно ни было, это не лампа, а связка программного обеспечения Linux + Apache + MySQL + PHP( Кстати, вместо PHP могут использоваться и другие скриптовые языки. Pyhon или Perl).
Apache – это бесплатный и самый популярный веб сервер под платформы GNU/Linux, Win32, Mac. Для него существует много документации на русском языке.
MySQL – СУБД ( система управления базой данных). В базе данных храниться практически вся информация, которая используется на сайте. Логины, ники, посты, и т.д.
PHP – Скриптовый язык программирования для веб приложений.

Приступим

Чтобы поставить всё нужное для организации веб сервера с поддержкой всех нужных инструментов на Linux нужно сделать следущие операции. Для начала нам нужен сам веб сервер Apache. Заходим в терминал и прописываем там команду:

sudo apt-get install apache2 libapache2-mod-auth-mysql

Эта команда скачает и установит с репозитория сам сервер Apache 2, и библиотеку libapache2-mod-auth-mysql.

Затем устанавливает интерпретатор php c дополнительными библиотеками:

sudo apt-get install php5-common php5 libapache2-mod-php5 php5-cli php5-cgi php5-mysql

Для того, чтобы всё заработало нужно перезапустить сервер Apache командой:

sudo /etc/init.d/apache2 reload

Теперь всё работает. Вы можете перейти по адресу localhost и перед вами появиться страница с текстом «Its Works ..» и так далее. Если так оно и есть, значит сервер Apache 2 работает. Проверить же работоспособность php можно создав файл c раcширением php в папке /var/www и открыть его в браузере через адрес

Читайте также:  Check if library installed linux

localhost/имя_вашего_файла.php. Чтобы внести изменения в этот каталог вам нужны права администратора, поэтому, вам нужно запустить ваш файловый менеджер от имени администратора. В Ubuntu это делает команда sudo nautilus. Допустим создайте файл test.php, в который вставьте , если по адресу localhost/test.php выдаст большую синюю страницу с информацией про сервер и настройки php, значит вам удалось установить php.Это выглядит примерно так:

После всех манипуляций с Веб сервером для возможности использовать полную динамичность веб программирования так-же стоит установить СУБД

MySQL. Нужно выполнить в терминале команду:

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

Это установит клиент и сервер СУБД MySQL. Установщик спросит пароль для пользователя root в СУБД MySQL. Если вы занимаетесь разработкой приложений, отладкой и тестированием, то можно ставить простой пароль для удобства.

Стоит так-же поставить phpMyAdmin для управления базой данных.

sudo apt-get install phpmyadmin

Выбираем apache2 из предложенного списка.

phpMyAdmin будет доступен по адресу localhost/phpmyadmin. Если при переходе по адресу выдает ошибку, попробуйте выполнить команды:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

sudo /etc/init.d/apache2 reload

Команда запуска, перезапуска, остановки сервера Apache:

sudo /etc/init.d/apache2 start

sudo /etc/init.d/apache2 reload

sudo /etc/init.d/apache2 stop

P.S. Apache стартует с системой, так-же как и сервер MySQL.

Источник

Apache2 mysql php phpmyadmin linux

This tutorial explains how to easily and quickly install an Apache2 web server as well as PHP 8, MariaDB (MySQL) and phpMyAdmin on your Linux root server or VPS/vServer. To do this, please follow these steps.

Hint: You can use the Tab key to autocomplete all filenames and directories, so you don’t have to type in the complete file or directory name manually.

Читайте также:  Linux рисование схемы сети

Note : This tutorial explains how to install PHP 8, but if you still want to install and use the previous version PHP 7.4, you can find the appropriate tutorial here.

This tutorial was last checked and updated on April 3, 2023.

Are you looking for very good, powerful and cheap servers? I’ve been renting my servers at Contabo for more than 10 years and I can highly recommend Contabo to everyone!

  1. If you havn’t already done so, download the program «PuTTY».
  2. Connect to your root server or VPS/vServer via SSH using PuTTY. To do this, open PuTTY and enter the domain or IP address of your server in the text box named «Host Name (or IP address)». Then click the «OK» button below.
  3. Update your package lists with the command apt update .
  4. Now install any available updates of the packages already installed on your server using the command apt upgrade -y .
  5. Next, install the packages needed for future installations in this tutorial by executing the following command: apt install ca-certificates apt-transport-https lsb-release gnupg curl nano unzip -y
  6. Add the repository needed to install PHP 8:
    For Debian:
    1. Use the command curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/php-archive-keyring.gpg to add the key needed for the PHP repository.
    2. Add the repository by executing the command echo «deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main» > /etc/apt/sources.list.d/php.list .
    1. Install the package for managing repositories using the following command: apt install software-properties-common -y
    2. Add the repository by executing the command add-apt-repository ppa:ondrej/php and pressing enter.
    1. Now enter the command mysql_secure_installation to complete the configuration of your MariaDB server. At the first question regarding the current password, you don’t have to type in anything, just press enter. Confirm the next question concerning the change of the root password with enter as well. Now you have to set a password for the MariaDB root user. There are no characters displayed during input, but this is normal. Confirm all further questions (deleting the anonymous user, disabling the external root login for security reasons, removing the test database and updating the privileges/permissions) also with enter. Then the MariaDB server is completely installed and configured.
    1. Now enter the command mysql_secure_installation to complete the configuration of your MariaDB server. At the first question regarding the current password, you don’t have to type in anything, just press enter. At the following question regarding switching to Unix socket authentication, type «n» and press Enter. Confirm the next question concerning the change of the root password with enter as well. Now you have to set a password for the MariaDB root user. There are no characters displayed during input, but this is normal. Confirm all further questions (deleting the anonymous user, disabling the external root login for security reasons, removing the test database and updating the privileges/permissions) also with enter. Then the MariaDB server is completely installed and configured.

    # phpMyAdmin Apache configuration

    Alias /phpmyadmin /usr/share/phpmyadmin

    1. Log in to your MariaDB server using the command mysql -u root .
    2. Execute the commands UPDATE mysql.user SET plugin = ‘mysql_native_password’ WHERE user = ‘root’ AND plugin = ‘unix_socket’; as well as FLUSH PRIVILEGES; . This will change the authentication plugin of the root user from the UNIX socket back to standard authentication.
    3. Finally leave the MariaDB console with the command exit .

    Источник

Оцените статью
Adblock
detector