There is another way to install LAMP on Ubuntu by using the tasksel
command, which provides an easy and convenient way to install software packages for specific tasks. Here’s how you can do it:
Step 1: Update System
- Open a terminal window on your Ubuntu server.
- Run the following command to update the system packages:
sudo apt update
- If prompted, enter your sudo password to authenticate.
Step 2: Install tasksel
- Run the following command to install tasksel:
sudo apt install tasksel
Step 3: Run tasksel to Install LAMP
- Run the following command to start tasksel:
sudo tasksel
- In the tasksel interface, use the arrow keys to navigate to “LAMP server” option.
- Press the spacebar to select it.
- Press Enter to continue.
- You will be prompted to set a root password for MariaDB during the installation process. Enter a strong password and remember it as you will need it later.
- Wait for the installation to complete. Tasksel will automatically install Apache, MariaDB, and PHP packages, and configure them for you.
Step 4: Verify Installation
- After installation, Apache, MariaDB, and PHP should be up and running.
- You can verify the status of Apache and MariaDB with the following commands:
sudo systemctl status apache2
sudo systemctl status mariadb
- To test PHP, you can create a PHP info file. Run the following command:
sudo nano /var/www/html/info.php
- In the text editor, enter the following PHP code:
<?php phpinfo(); ?>
- Save and close the file.
- Open a web browser and enter the URL
http://<your-server-ip>/info.php
. You should see the PHP info page, which confirms that PHP is working correctly.
That’s it! You have now successfully installed LAMP (Linux, Apache, MariaDB, PHP) stack on your Ubuntu server using the tasksel
command. You can proceed to build and host your web applications using this environment.
Is MariaDB or MySQL?
If you use tasksel
to install the LAMP stack on Ubuntu, it will install MariaDB as the default database management system (DBMS), not MySQL.
MariaDB is a popular open-source relational DBMS that is a drop-in replacement for MySQL. It was created by the original developers of MySQL and is designed to be compatible with MySQL in terms of database structure and APIs, while also providing additional features and performance improvements.
When you select the “LAMP server” option in tasksel
, it will automatically install MariaDB along with Apache (web server) and PHP (server-side scripting language) to create a complete web server environment on your Ubuntu system. During the installation process, you will be prompted to set a root password for MariaDB, and the system will configure MariaDB for you.
Note: In some Ubuntu versions, tasksel
may install MySQL instead of MariaDB due to package availability. However, it is recommended to use MariaDB, as it is a widely used and actively developed alternative to MySQL.
Should execute mysql_secure_installation or not?
If I used tasksel to install LAMP, and mairadb get installed. Do I still need to run “sudo mysql_secure_installation” command to configure mariadb?
Yes, it is recommended to run the “sudo mysql_secure_installation” command after installing MariaDB via tasksel or any other method on Ubuntu, in order to configure MariaDB and enhance its security.
The “mysql_secure_installation” script is a MySQL/MariaDB utility that helps you perform important security-related tasks, such as setting the root password, removing anonymous users, disabling remote root login, and removing test databases, among others. By running this command, you can secure your MariaDB installation and protect it against potential security threats.
Even though tasksel may install MariaDB with some default security settings, it is still a good practice to run “mysql_secure_installation” to ensure that your MariaDB installation is properly configured according to your security requirements. It is always important to prioritize the security of your database system to safeguard your data and prevent unauthorized access.