phpMyAdmin is an open source tool for managing and interacting with MySQL databases. phpMyAdmin uses a web-based management interface which allows users to interact with databases through web browser. It allows us to manage database users and privileges, import and export databases, execute database queries and more.
Start by updating the system. You can use the below command.
yum update -y
Step2. Add Repo
Since phpMyAdmin is not available in CentOS 7’s default repository, we need to add the Extra Packages for Enterprise Linux (EPEL) repo by executing the below command.
yum install epel-release -y
Step 3. Install phpMyAdmin
After adding the repo, you can install phpMyAdmin using the yum package by typing the below command:
yum install phpmyadmin -y
For phpMyAdmin to work properly, we need to make some changes to the configuration file. Open the configuration file using your text editor.
vi /etc/httpd/conf.d/phpMyAdmin.conf
By default the configuration is set up to access the connection only from localhost. In order to work remotely, you will need to specify the addresses in the configuration file.
Add your remote IP to the respective lines on the configuration as shown below.
Require ip your_ip_addressAllow from your_ip_address
Restart Apache to apply the modifications.
systemctl restart httpd
Now you can access phpMyAdmin using the URL below.
http://server_domian_or_ip/phpmyadmin
How To Install phpMyAdmin in CentOS 7
To login, use a valid username and password of a MariaDB user. You can the root user and MariaDB administrative pass to login by default. You can then access the administrative interface:
How To Install phpMyAdmin in CentOS 7
Conclusion
You’ve successfully installed phpMyAdmin on your CentOS 7 machine. Now you can manage your databases through a web interface. You can manage databases, users, and tables, perform various other MySQL queries and operations.
LEMP stack is a group of open source software that is installed on a server so that we can host dynamic web applications and sites. LEMP stack is an another variation of the LAMP stack. LEMP is an acronym which consists of Linux as the operating system, NGINX as the web server, MySQL/MariaDB as the relational database management system and PHP as the server-side scripting language.
Log in as a sudo user and then update your system using the following command,
yum update -y
Step 2: Installing NGINX
Nginx is not available on the default CentOS 7 repositories, so add the Extra Packages for Enterprise Linux (EPEL) repository by executing the command below.
yum install epel-release -y
Now that the (EPEL) repository repository is installed on your server, let’s install the NGINX Web Server using the command below.
yum install nginx -y
After the installation, start and enable NGINX.
systemctl start nginxsystemctl enable nginx
Configure the system firewall for NGINX to allow 80 and 443 inbound to the server.
To verify if NGINX is running, visit your IP address via the browser.
http://server_domain_name_or_IP/
You should see the default NGINX page as shown below.
Step 3: Installing MariaDB
MariaDB – a drop in replacement of MySQL, is the default database management system in CentOS 7. It is a community-developed fork of the MySQL relational database management system.
MariaDB comes with default CentOS repositories, thus run the following command to install it.
yum install mariadb-server mariadb -y
After the installation is complete, start and enable the service.
systemctl start maridbsystemctl enable mariadb
Run the following command to prevent all unauthorized accesses and remove some dangerous defaults in your database configuration.
mysql_secure_installation
You will be prompted with an option to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of localhost, remove test databases and reload privileges. It is recommended that you answer ‘yes’ to these options to secure the database server.
Step 4: Installing PHP
PHP is a widely used scripting language suited for web development. By default PHP 5.4 is available in the CentOS 7 Yum repositories. It is now outdated and no longer supported. We recommend that you install the latest stable version of PHP 7.x as it has many improvements and new features.
To install the latest PHP version we need to add REMI repository. Lets start by installing the package “yum-utils” for configuring yum repositories and install the REMI repository.
Configure the repository for installing PHP 7.3 (or the latest stable version) using the following command. If there is a later version then simply modify the command by changing the version numbers in the command to match the release you wish to install.
yum-config-manager --enable remi-php73
We can now install PHP 7.3 along with its common dependencies with the command below,
yum install php php-mysql php-fpm -y
Check the PHP version with the command below,
php -v
The output should look similar to what show below,
PHP 7.3.2 (cli) (built: Feb 5 2019 13:10:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies
By default PHP-FPM is configured to user “apache” on port 9000. W’ll need to change the user to nginx.
To do so edit the PHP-FPM configuration file at “/etc/php-fpm.d/www.conf” to what’s shown below.
...
user = nginx
...
group = nginx
...
listen = /run/php-fpm/www.sock
...
listen.owner = nginx
listen.group = nginx
Save the file and change the ownership of the directory “/var/lib/php” from “apache” to “nginx”.
chown -R root:nginx /var/lib/php
Start and enable PHP-FPM.
systemctl start php-fpm
systemctl enable php-fpm
Step 5: Configuring Nginx to Process PHP Pages
Create a new NGINX configuration file with the following command.
vim /etc/nginx/conf.d/default.conf
Paste the syntax below on to the newly created configuration file.
server {
listen 80;
server_name your_server_ip;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Note: Replace “your_server_ip” with your actual server IP.
Save the file and restart NGINX for the changes to take effect.
systemctl restart nginx
Conclusion
Now that you have successfully installed LEMP stack, you are now ready to host any type of dynamic website/software applications.
LAMP is a set of open source software packages that is used to create websites and web applications. LAMP is an acronym. It consists of Linux as the operating system, Apache as the Web server, MySQL/MariaDB as the relational database management system and PHP as the server-side scripting language. In this document, we will go through the steps necessary for installing the LAMP stack on a CentOS 7 server.
All you require for these operations is a VPS with CentOS 7 installed on it and root/root privileged user access to the server.
Check whether Apache is running by calling your IP/hostname in the browser. If Apache is running the default CentOS 7 Apache web page will be displayed.
Apache Test Page on CentOS 7 Server
Step 3: Install MariaDB Database
MariaDB is a drop-in replacement for MySQL. It is a reliable SQL server that comes with a rich set of enhancements and features. For dynamic websites, it is always necessary to store data. We can install MariaDB together with additional packages that are required by running the commands below:
sudo yum install mariadb-server mariadb -y
Now that the MariaDB has installed successfully, run the command below to start and enable the service.
To prevent unauthorized access to your database and remove some dangerous defaults run the following command.
sudo mysql_secure_installation
You will be prompted with an option to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of localhost, remove test databases and reload privileges. It is recommended that you answer ‘yes’ to these options to secure the database server.
Step 4: Install PHP
PHP is a widely used scripting language suited for web development. It works with Apache to display the dynamic content for your website. By default, PHP 5.4 is available in the CentOS 7 Yum repositories. We recommend that you install the latest stable version of PHP 7.x as it has many improvements and new features.
To install the latest PHP version we need to add EPEL and REMI repositories. Let’s start by installing the package “yum-utils” for configuring yum repositories and enabling the EPEL repository.
Configure the repository for installing PHP 7.3 (or the latest stable version) using the following command. If there is a later version then simply modify the command by changing the version numbers in the command to match the release you wish to install.
yum-config-manager --enable remi-php73
We can now install PHP 7.3 along with its SQL dependency using the command below.
yum install php php-mysql -y
After installing PHP, restart the Apache service.
sudo systemctl restart httpd
Conclusion
That’s it. You’ve successfully installed the LAMP platform on your CentOS 7 system which can now run dynamic website and software applications. Depending on your web hosting needs, you might also need to install additional Apache modules and PHP extensions.
We highly recommend checking out OpenLiteSpeed web server as an open-source drop-in replacement for Apache. There can be significant speed increases by running OpenLiteSpeed. We have an article on how to install OpenLiteSpeed to help guide you.