LoginSignup
0
1

More than 3 years have passed since last update.

RaspberryPi への LAMP 環境の構築

Last updated at Posted at 2020-12-09

RaspberryPiにLAMP環境を準備するメモです。

この記事を書くにあたってのRaspberryPi OSのバージョンは次の通りでした。

pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
pi@raspberrypi:~ $

参考としたページは、次のページです。
ありがとうございます。
というか、先達のページをなぞっただけの投稿です。
http://marchan.e5.valueserver.jp/cabin/comp/jbox/arc112/doc11205.html

Apache2 と phpのインストール

apache2をインストールします

sudo apt update
sudo apt install apache2

phpをインストールします

sudo apt install php php-cli php-curl

userdirでもphpが使えるようにapache2の設定を行います。

sudo a2enmod userdir

次のファイル中でuserdirのphpを止めているので、コメントアウトします。

sudo vi /etc/apache2/mods-enabled/php7.3.conf
##<IfModule mod_userdir.c>
## <Directory /home/*/public_html>
## php_admin_flag engine Off
## </Directory>
##</IfModule>

apache2を再起動して反映します。

sudo systemctl restart apache2

確認のため、.phpのファイルを書きます

pi@raspberrypi:~/public_html $ cat> index.php
<HTML><HEAD></HEAD>
<BODY>
<?php
phpinfo();
?>
</BODY>
</HTML></HTML>
Ctrl+C

ブラウザでファイルを開きます。
http://localhost/~pi/

MySQL/MeriaDBのインストール

MySQL/MeriaDBをインストールします。

sudo apt-get -y install php-mysql
sudo apt-get install mariadb-server
sudo systemctl start mariadb.service

初期設定を実施します。

sudo mysql_secure_installation

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

Remove anonymous users? [Y/n] y
... Success!

Disallow root login remotely? [Y/n] y
... Success!

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reload privilege tables now? [Y/n] y
... Success!

Thanks for using MariaDB!

phpmyadmin のインストール

sudo apt-get -y install phpmyadmin

パッケージの設定

│ [*] apache2

│ phpmyadmin 用のデータベースを dbconfig-common で設定しますか? │ <はい>

パッケージの設定

│ phpmyadmin 用の MySQL アプリケーションパスワード:

pi@raspberrypi:~/public_html $ sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 71
Server version: 10.3.27-MariaDB-0+deb10u1 Raspbian 10

MariaDB [mysql]> UPDATE user SET plugin='' WHERE User='root';
Query OK, 1 row affected (0.037 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.009 sec)

以上です。
次は、QRコードリーダ使って、jukebox作ります。
クリスマスソング用

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1