naos 2017/10/26 20:43

LEMP (Linux Nginx Mariadb Php)

testé sur CentOS 7

# yum install epel-release

# yum install nginx

# yum install mariadb-server mariadb

# yum install php php-mysql php-fpm

# systemctl start nginx

# systemctl enable nginx

# firewall-cmd –permanent –zone=public –add-service=http

# firewall-cmd –permanent –zone=public –add-service=https

# firewall-cmd –reload

# systemctl start mariadb

# mysql_secure_installation

# vim /etc/php.ini, s'assurer d'avoir cette ligne:

cgi.fix_pathinfo=0

# vim /etc/php-fpm.d/www.conf, changez les lignes:

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx

# systemctl start php-fpm

# systemctl enable php-fpm

# vim /etc/nginx/conf.d/default.conf

 server {
    listen       80;
    server_name  DOMAIN_OU_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;
    }
 }

# systemctl restart nginx

Vous pouvez maintenant tester le fonctionne du LEMP en créant un fichier inf.php:

# vim /usr/share/nginx/html/info.php

<?php phpinfo(); ?>

Ce fichier étant contenant beaucoup d'informations sur votre machine n'oubliez pas ensuite de supprimer ce fichier par mesure de sécurité.

# rm /usr/share/nginx/html/info.php

  • lemp.txt
  • Dernière modification: 2017/11/02 21:19
  • par naos