Jump to content

LAMP

From Wiki
Source: digitaloceanspaces.com

Update Software Packages

sudo apt update
sudo apt upgrade

Install Apache Web Server

sudo apt install -y apache2 apache2-utils

After it’s installed, Apache should be automatically started. Check its status with systemctl.

systemctl status apache2

If it’s not running, use systemctl to start it.

sudo systemctl start apache2

It’s also a good idea to enable Apache to automatically start at system boot time.

sudo systemctl enable apache2

Check Apache version:

apache2 -v

If you are using UFW firewall, then run this command to open TCP port 80.

sudo ufw allow http

Now we need to set www-data (Apache user) as the owner of document root (otherwise known as web root). By default it’s owned by the root user.

sudo chown www-data:www-data /var/www/html/ -R

Then enable this config file.

sudo a2enconf servername.conf

Reload Apache for the change to take effect.

sudo systemctl reload apache2

Install MariaDB Database Server

sudo apt install mariadb-server mariadb-client

After it’s installed, MariaDB server should be automatically started. Use systemctl to check its status.

systemctl status mariadb

If it’s not running, start it with this command:

sudo systemctl start mariadb

To enable MariaDB to automatically start at boot time, run

sudo systemctl enable mariadb

Now run the post-installation security script.

sudo mysql_secure_installation

So you can run the following command to login without providing MariaDB root password.

sudo mariadb -u root

To exit, run

exit;

Check MariaDB server version information.

mariadb --version

Install PHP7.4

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline

Enable the Apache php7.4 module then restart Apache Web server.

sudo a2enmod php7.4
sudo systemctl restart apache2

Check PHP version information.

php --version

Run PHP-FPM with Apache

Disable the Apache PHP7.4 module.

sudo a2dismod php7.4

Install PHP-FPM.

sudo apt install php7.4-fpm

Enable proxy_fcgi and setenvif module.

sudo a2enmod proxy_fcgi setenvif

Enable the /etc/apache2/conf-available/php7.4-fpm.conf configuration file.

sudo a2enconf php7.4-fpm

Restart Apache for the changes to take effect.

sudo systemctl restart apache2

Terkait

Source