آموزش کامل نصب LAMP در Ubuntu 20.04

بسته نرم افزاری LAMP یکی از پکیج های نرم افزاری محبوب و اساسی برای سرور هست که شامل نصب وب سرور Apache، دیتابیس MariaDB یا MySQL و PHP که روی سیستم عامل لینوکس نصب می شود که در این آموزش ما قصد داریم نحوه نصب این بسته روی توزیع اوبونتو را به طور کامل به شما آموزش بدیم پس پیشنهاد میکنیم در ادامه با آموزش کامل نصب LAMP در Ubuntu 20.04 همراه ما باشید.
آموزش کامل نصب LAMP در Ubuntu 20.04
پیش از شروع نصب توجه کنید که از قبل باید اوبونتو روی سیستم یا سرور شما نصب شده باشد. همچنین پیش از شروع نصب بسته، پیشنهاد میکنیم با استفاده از دستور زیر مخزن بسته های نرم افزاری را به روز رسانی کنید.
sudo apt update
نصب وب سرور آپاچی روی Ubuntu
با استفاده از دستور زیر پکیج apache2 را روی سرور نصب میکنیم.
sudo apt -y install apache2 apache2-utils
بعد از نصب با دستور زیر میتونیم وضعیت وب سرور را بررسی کنیم.
systemctl status apache2
در صورتی که آپاچی شروع به کار نکرده بود با دستورات زیر این کار را انجام میدیم.
sudo systemctl start apache2 sudo systemctl enable apache2
به کمک دستورات و مراحل زیر هم میتونید فایروال را برای آپاچی تنظیم کنید.
sudo ufw app list
خروجی:
Available applications: Apache Apache Full Apache Secure OpenSSH
اگر از SSL استفاده نمی کنید، با دستور زیر پورت 80 را باز کنید اما اگر از SSL استفاده می کنید جای کلمه apache در این دستور، Apache Secure را جایگزین کنید.
sudo ufw allow in "Apache"
نصب MariaDB روی Ubuntu
حال مراحل نصب دیتابیس MariaDB رو انجام میدیم و با دستور زیر دیتابیس را نصب میکنیم
sudo apt install -y mariadb-server mariadb-client
با اجرای دستور زیر دیتابیس را کانفیگ می کنیم.
sudo mysql_secure_installation
خروجی:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure 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): << فقط Enter بزنید 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 << Set MariaDB root password New password: xxx << یک رمز root برای دیتابیس مشخص کنید Re-enter new password: xxx << رمز را تکرار کنید 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 << کلید Y و Enter بزنید ... 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 << با زدن 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 for using MariaDB!
نصب PHP روی Ubuntu
چون وب سرور آپاچی به طور پیشفرض فقط از فایل های HTML پشتیبانی میکنه، برای پشتیبانی از PHP باید PHP و اکستنشن های اون را برای MariaDB نصب کنیم که اینکار را با دستور زیر انجام میدیم.
sudo apt install -y php php-mysql libapache2-mod-php
بعد از نصب PHP با دستور فوق یکبار وب سرور را مجدد راه اندازی میکنیم.
sudo systemctl restart apache2
با وارد کردن آدرس http://your-ip-addr.ess/info.php میتونید وضعیت دسترسی به صفحه تست PHP و مشخصات اون را بررسی کنید.
در اینجا به پایان این آموزش از وبلاگ آموزشی پرداز آی تی رسیدیم و امیدواریم که آموزش کامل نصب LAMP در Ubuntu 20.04 برای شما کاربردی و مفید واقع شده باشد.