Nginx, PHP and the database (MySQL and or MariaDB) are three things that many bloggers uses as their environment to host their blog. These three combinations of software are well-known as LEMP, stands for Linux, Nginx (engine x) and php. It is needed to configure appropriately to make the most power of them. Otherwise, yeah, you have a blog running like everyone else.
Once these elements are set up and configured, we can install WordPress, Joomla or perhaps Drupal. They are three the popular cms out there on the net.
It is not hard to install this three fantastic software. Below is the necessary step on how to install LEMP on centos 7.
1). Establish an ssh connection with centos 7 servers using ssh client, the good one is putty, using username and password that should be created after getting root with a password.
2). Install Nginx. To do this, follow these steps :
a). Download Nginx signing key.
b). Install Nginx signing key :
c). Add nginx repo. There is two version of Nginx, stable and mainline. I use mainline.
Copy and paste below into nginx.repo :
d). Run the command
e). Check nginx version by run the command
If you want to implement any other module that is not listed in nginx by default, compile Nginx from source is the solution.
f). Nginx list command line:
To start nginx :
To restart nginx :
To stop nginx :
To enable nginx :
3). Install mariadb or mysql. Mariadb and or Mysql server, which one you prefer to install, must be installed to store the data. To work with a database from a command line, MySQL or MariaDB client is the solution.
3.1). Install mysql server and client :
a). Download MySQL, available free at dev.mysql.com/downloads/repo/yum.
b). Install MySQL.
3.2). For mariadb server and client :
a). Create mariadb repo.
b). Copy and paste below into mariadb.repo.
c). Install mariadb
3). To secure MariaDB or mysql installation, then run the command in terminal.
For resetting the password options, choose "n" , to use the password used in first-time setup database. Then several options will appear, choose "y" is the best answer.
4). Install PHP. PHP is one of the most programming language used by many bloggers. In fact, Wordpress is written in PHP, and is used by blogger around the world. On the net, many people will teach about any other programming language, and still use WordPress.
There are several options, how php can be implemented on centos 7. PHP 7.2 is the latest version of PHP, I think we should use it as it has more features than the older ones.
4.1). Install php 7.2 via yum provided by Webtatic
a). Provide Webtatic yum repository by typing this in the command line :
b). Install php-fpm to connect to database and nginx web server.
4.2). Install php 7.2 using Remis RPM Repository
a). Add remis rpm repository
b). Enable and Activate it
c). Install php 7.2
4.3). Check php version
5). Create php file, named info.php, inside root folder of the web to check that is everything work properly.
Copy and paste the following inside info.php :
6). Navigate to my_ip_address/info.php. If all goes well, it will give useful information about PHP modules that have been installed, predefined variables system on given system and short info of configuration of the database.
For the security reason, do a change to your php.ini so that you have the code below inside it :
Once these elements are set up and configured, we can install WordPress, Joomla or perhaps Drupal. They are three the popular cms out there on the net.
It is not hard to install this three fantastic software. Below is the necessary step on how to install LEMP on centos 7.
1). Establish an ssh connection with centos 7 servers using ssh client, the good one is putty, using username and password that should be created after getting root with a password.
2). Install Nginx. To do this, follow these steps :
a). Download Nginx signing key.
'sudo wget http://nginx.org/keys/nginx_signing.key '
b). Install Nginx signing key :
' sudo rpm --import nginx_signing.key '
c). Add nginx repo. There is two version of Nginx, stable and mainline. I use mainline.
' sudo nano /etc/yum.repos.d/nginx.repo '
Copy and paste below into nginx.repo :
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7.4/$basearch/
gpgcheck=1
enabled=1
d). Run the command
' sudo yum install nginx '
e). Check nginx version by run the command
' nginx -v '
If you want to implement any other module that is not listed in nginx by default, compile Nginx from source is the solution.
f). Nginx list command line:
To start nginx :
' sudo systemctl start nginx '
To restart nginx :
' sudo systemctl restart nginx '
To stop nginx :
' sudo systemctl stop nginx '
To enable nginx :
' sudo systemctl enable nginx '
3). Install mariadb or mysql. Mariadb and or Mysql server, which one you prefer to install, must be installed to store the data. To work with a database from a command line, MySQL or MariaDB client is the solution.
3.1). Install mysql server and client :
a). Download MySQL, available free at dev.mysql.com/downloads/repo/yum.
' sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm '
b). Install MySQL.
' sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm '
3.2). For mariadb server and client :
a). Create mariadb repo.
' sudo nano /etc/yum.repos.d/mariadb.repo '
b). Copy and paste below into mariadb.repo.
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
c). Install mariadb
' sudo yum install MariaDB-server MariaDB-client '
3). To secure MariaDB or mysql installation, then run the command in terminal.
' sudo mysql_secure_installation '
For resetting the password options, choose "n" , to use the password used in first-time setup database. Then several options will appear, choose "y" is the best answer.
4). Install PHP. PHP is one of the most programming language used by many bloggers. In fact, Wordpress is written in PHP, and is used by blogger around the world. On the net, many people will teach about any other programming language, and still use WordPress.
There are several options, how php can be implemented on centos 7. PHP 7.2 is the latest version of PHP, I think we should use it as it has more features than the older ones.
4.1). Install php 7.2 via yum provided by Webtatic
a). Provide Webtatic yum repository by typing this in the command line :
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
b). Install php-fpm to connect to database and nginx web server.
' yum install php72w-fpm '
4.2). Install php 7.2 using Remis RPM Repository
a). Add remis rpm repository
' wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm '
b). Enable and Activate it
' yum install yum-utils
yum-config-manager --enable remi-php72 '
c). Install php 7.2
' sudo yum install php72-fpm '
4.3). Check php version
' php -v '
5). Create php file, named info.php, inside root folder of the web to check that is everything work properly.
' sudo nano /var/www/html/info.php '
Copy and paste the following inside info.php :
'
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
'
6). Navigate to my_ip_address/info.php. If all goes well, it will give useful information about PHP modules that have been installed, predefined variables system on given system and short info of configuration of the database.
For the security reason, do a change to your php.ini so that you have the code below inside it :
"cgi.fix_pathinfo = 0;"