How to serve PHP files on Nginx

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Let's see how to use Nginx to host a PHP website and solve the problems:
    Nginx 403 forbidden
    PHP file downloaded instead of run
    Nginx configuration file with PHP support:
    server {
    listen 80;
    server_name your_server_domain_or_IP;
    root /var/www/html;
    index index.php index.html index.htm;
    location / {
    try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.x-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }
    }

Комментарии • 4

  • @nhatlequocnhat7183
    @nhatlequocnhat7183 2 месяца назад

    Really Intuitive for the beginner, Thank you so much

    • @absprog
      @absprog  2 месяца назад

      Glad it was helpful!

  • @Cyborg-h6h
    @Cyborg-h6h 4 дня назад

    thanks alot. helped me a bunch

    • @absprog
      @absprog  4 дня назад

      Glad to hear that