ติดตั้งเว็บเซิร์ฟเวอร์ LAMP ประกอบด้วย Apache, PHP และฐานข้อมูล MySQL หรือ MariaDB บน ระบบปฏิบัติการ Ubuntu Server 20.04.4 LTS
Install LAMP Ubuntu Server 20.04.4 LTS
1. ติดตั้ง Apache
Web Server
# apt -y install apache2
2. ติดตั้ง PHP
# apt -y apt -y install php php-cgi
libapache2-mod-php php-common php-pear php-mbstring
3. ตรวจสอบเวอร์ชั่น PHP
# php -v
4. ตั้งค่า PHP
# nano /etc/php/7.4/apache2/php.ini
เพิ่ม
date.timezone = Asia/Bangkok
5. เปิดใช้งาน apache2
# systemctl restart apache2
6. ติดตั้ง MariaDB 10.6
# apt install software-properties-common -y
# curl -LsS -O
https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
# bash mariadb_repo_setup --mariadb-server-version=10.6
# apt update
# apt -y install mariadb-common mariadb-server-10.6
mariadb-client-10.6
7. เปิดใช้งาน MariaDB 10.6
# systemctl start mariadb
# systemctl enable mariadb
8. ติดตั้ง
Root Password ก่อนสร้างฐานข้อมูล Database
#
mysql_secure_installation
Enter current
password for root (enter for none): Press Enter
Switch to unix_socket
authentication [Y/n] y
Change the root
password? [Y/n] y
New password:
Re-enter new
password:
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
9. ตรวจสอบฐานข้อมูล
# mysql
> show grants for
root@localhost;
+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for
root@localhost
|
+--------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL
PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket USING
'*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION |
| GRANT PROXY ON
''@'%' TO 'root'@'localhost' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------------------------+
> select
user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost |
*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------+-----------+-------------------------------------------+
1 row in set (0.001
sec)
> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema
|
| mysql |
| performance_schema
|
+--------------------+
3 rows in set (0.001
sec)
> exit