LAMP Stack stands for Linux, Apache, MariaDB and PHP. It is most widely used to host websites, blogs, etc.
Below is a small guide on installing and configuring LAMP Stack with the latest release of CentOS 8.
Install Apache Web Server
- The package name of Apache is httpd. Use a package manager yum to install
# yum install -y httpd
- Start the Apache service using the command systemctl
# systemctl start httpd
- The configuration allows Apache to be started on the same system
# systemctl enable httpd
- Check the Apache service status using the command below
# systemctl status httpd
- Check Apache's default port
# ss -plnt | grep httpd
LISTEN 0 128 *:80 *:* users:(("httpd",pid=9339,fd=4),("httpd",pid=9338,fd=4),("httpd",pid=9337,fd=4),("httpd",pid=9335,fd=4))
Accordingly, the default port Apache uses is port 80.
- Firewall configuration
By default, the firewall blocks HTTP connections coming from external machines. So to test or use the Apache web server, we need to configure the firewall to allow HTTP requests from external machines.
# firewall-cmd --permanent --add-port=80/tcp # firewall-cmd --reload
- Test Apache's performance
Open your browser, enter the server's IP address search bar. You will get the result as Apache test page. This test page confirms that Apache is working fine.
Apache's default document root is / var / www / html, the main configuration file is /etc/httpd/conf/httpd.conf. Additional configurations for Apache web server are stored in /etc/httpd/conf.d directory
This guide will guide you to install MariaDB from the operating system repository. You can also install MariaDB from the MariaDB community repository.
READ: Install MariaDB 10.4.8 on CentOS 8
- Use the following command to install
# yum install -y mariadb mariadb-server
- Start the MariaDB Server service with the systemctl command
# systemctl start mariadb
- Configuration allows the MariaDB Server service to start with the system
# systemctl enable mariadb
- Check the status of MariaDB Server services
# systemctl status mariadb
Commands to use
This command allows you to improve the security of your MariaDB installation in the following ways:
- Set a password for the root account.
- Delete the root account accessible from outside localhost.
- Delete anonymous user accounts.
- Delete the test database (by default it can be accessed by all users, even anonymous users) and privileges allow anyone to access the database whose name begins with test_.
By default Apahe Web Server only supports HTML languages. For PHP support we will have to install the PHP package.
CentOS 8 uses PHP v7.2 by default. In case you want to use PHP v7.3 you can follow the following instructions
READ: How to install PHP v7.3 on CentOS 8
- PHP install command
# yum install -y php php-mysqlnd
- Restart the Apache Web Server service again to confirm the use of PHP
# systemctl restart httpd
Test LAMP Stack
To test PHP, create an info.php file in the default Apache directory
# echo "<?php phpinfo()?>" > /var/www/html/info.php
Then use your browser to enter the following address search bar, replacing 192.168.136.100 with your Server IP address.
Your page will then look like this. You can see information about the installed PHP version, extension details, etc.
Scroll down the browser to check support for MariaDB. You will get the screen as below.
- Themify Magazine v2.2.2 - A True Drag & Drop Builder for Magazine Layouts
- Tips for "cricket" is used in the water well
- 12 latest WordPress themes on Themeforest
- Bitcoin is expected to plummet if it fails to break $ 10K soon
- May khăn tay lau bếp cực dễ