7. Install PHP
PHP is the server-side scripting language for Web-based services. It is also often used as a general programming language. To install PHP in a minimized installation of CentOS:
# Yum Install PHP
After installing PHP, confirm that the Apache service is restarted to render PHP in a Web browser.
# systemctl Restart Httpd.service
Next, verify PHP by creating the following PHP script in the Apache document root directory.
# echo-e "<?php/nphpinfo ();/n?>" >/var/www/html/phpinfo.php
Now view the PHP file (phpinfo.php) that we just created on the Linux command line.
# php/var/www/html/phpinfo.php or # links http://127.0.0.1/phpinfo.php
Verifying PHP
8. Installing the MariaDB Database
MariaDB is a branch of MySQL. RHEL and its derivative version have migrated from MySQL to MariaDB. This is a mainstream database management system and a tool that you have to have. No matter what server you're configuring, you'll need it sooner or later. Install the MariaDB on a minimized CentOS installation, as follows:
# yum Install Mariadb-server mariadb
Installing the MariaDB Database
Start MariaDB and configure it to start automatically when it is powered on.
# Systemctl start mariadb.service# systemctl enable Mariadb.service
Allow MySQL (mariadb) service to pass through the firewall (LCTT: If your mariadb is only used on this computer, be sure not to set up a firewall that allows you to connect to your database using a UNIX Socket; If you need to connect to a database on a different server, use the internal network as much as possible. Instead of exposing the database service to the public Internet. )
# Firewall-cmd–add-service=mysql
It's time to make sure the MariaDB server is secure (LCTT: This step is to set the MySQL admin password).
#/usr/bin/mysql_secure_installation
Protecting the MariaDB database
Please read:
- Installing LAMP on CentOS 7.0 (Linux, Apache, MariaDB, Php/phpmyadmin)
- Creating an Apache virtual host on CentOS 7.0
9. Installing and configuring the SSH server
SSH is Secure Shell, which is the default protocol for Linux remote management. SSH is one of the most important software to run with the minimal installation of the CentOS server.
Check the currently installed SSH version.
# ssh-v
Check SSH version
Use a more secure SSH protocol instead of the default protocol, and change the port number to further enhance security. Edit the SSH configuration file '/etc/ssh/ssh_config '.
Remove the comment from the line below or delete 1 from the Protocol line, and the line looks like this (LCTT: SSH v1 is an outdated, deprecated, insecure protocol):
# Protocol 2,1 (original) Protocol 2 (now)
This change forces SSH to use protocol 2, which is considered more secure than Protocol 1, and also ensures that the port number 22 is changed in the configuration.
Secure SSH Login
Cancel the ' root login ' in SSH and allow only a normal user account to log in before using Su to switch to root to further enhance security. Please open and edit the configuration file '/etc/ssh/sshd_config ' and change permitrootlogin Yes to Permitrootlogin No.
# Permitrootlogin Yes (original) Permitrootlogin No (now)
Cancel SSH Root Direct Login
Finally, restart the SSH service to enable the changes.
# systemctl Restart Sshd.service
10. Installing GCC (GNU compiler Set)
GCC, the GNU compiler set, is a compilation system developed by the GNU project that supports multiple programming languages (LCTT: You need it when you need to build your own software). There is no default installation of CentOS in the minimized installation. Run the following command to install the GCC compiler.
# yum Install gcc
Installing GCC on CentOS
Check the installed GCC version.
# gcc--version
Check GCC version
11. Installing Java
Java is a common class-based, object-oriented programming language. There is no default installation in the minimized CentOS server (LCTT: If you do not have any Java applications, you can not install it). Follow the command below to install Java from the library.
# yum Install Java
Installing Java
Check the Java version of the installation.
# java-version
Check the Java version
30 things to do after installing the minimized Rhel/centos 7 (ii) reproduced from the Code of the Rural network