The proceed here is to get a LEMP (Linux + ENginx + MySQL + PHP) installed in Centos 7.x.

  1. {{yum install epel-release}} , this is for install the EPEL repository
  2. {{curl ’’ -o setuh}}
  3. {{bash}}
  4. {{yump update}} to update the server
  5. {{yum install vim}} to install Vim editor

Note: To use Vim is necesary to know some basics. For insert content hit *i*. For out of edit mode hit *Esc*. To save and quit hit *:wq*. To quit hit *:q*. To quit without save hit *:q!*. To delete line hit *dd*.

Installing Nginx

  1. yum install nginx
  2. systemctl start nginx # this will to start the Nginx service
  3. systemctl enable nginx # will enable to start Nginx on boot
  4. curl http://DOMAIN_NAME_OR_IP #using welcome page of Nginx to test if is working, even if the port 80 is still close

Install MariaDB

  1. {{yum install mariadb-server mariadb}}, to install MariaDB
  2. {{systemctl start mariadb}} starting the service
  3. {{mysql_secure_installation}} this is an interactive script that will help us to secure the MariaDB server:
  4. {{systemctl enable mariadb}} to enable start the MariaDB on boot

Install PHP

  1. {{yum install php70u-fpm-nginx php70u-cli php70u-mysqlnd}} installing php and the php-fpm service *all this for PHP 7*
    {{vim /etc/php.ini}}
  2. We need to search the line that has {{cgi.fix_pathinfo=1}} and change the value to 1, this is for some security concerns. Save and exit.
  3. Then we need to edit {{vim //etc/php-fpm.d/www.conf}} for the PHP-FPM settings
  4. And change the “listen” parameter to {code}listen = /run/php-fpm/www.sock{code}
  5. Then we need to change other values to:
  6. {code}listen.owner = nobody = nobody
    user = nginx
    group = nginx
    listen.acl_users = nginx{code}
  7. Now it is needed to change the definition of a _upstream_ in order to Nginx can use it in several places, edit {{vim /etc/nginx/conf.d/php-fpm.conf}} and should look like: {code}upstream php-fpm {
    server unix:/run/php-fpm/www.sock;
  8. {{systemctl start php-fpm}} to start the service
  9. {{systemctl enable php-fpm}} to enable start the serve in the boot

Configure Nginx to process PHP

  1. We need to open {{vim /etc/nginx/nginx.conf}} and add: {code} http {

    include /etc/nginx/sites-enabled/*;
    }{code} In the {{sites-enabled}} directory will be the configurations for the virtualhosts that are gonna be available
  2. Find or create the file and open with vim {{/etc/nginx/conf.d/default.conf}} {code} server {
     listen 80;
     server_name SERVER_DOMAIN_NAME_OR_IP;
     # note that these lines are originally from the "location /" block
     root /path/to/your/location/of/site/files/public/folder;
     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 php-fpm;
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;
  3. {{systemctl restart nginx}} to restart Nginx server

Test PHP on your web server

  1. Create in your root directory of your virtualhost a file called {{info.php}}
  2. Open the file and add this content {code}{code}
  3. Open in the browser the URL: {{http://your_server_IP_address/info.php}} and you should see the PHP info
  4. Remove the {{info.php}} file

If the port 80 is blocked

  1. check the firewall firstly using {{ipatables -L}}
  2. If zones are being used check it with {{firewall-cmd –get-active-zones}}
  3. Add the 80 port to the public zone {{firewall-cmd –zone=public –add-port=80/tcp –permanent}}


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s