Question

404 error nginx php problem.

Posted November 1, 2021 126 views
NginxPHPWordPressLEMP

Greetings, First of all huge thanks to all the people who wrote guides and are helping people understand more how to do stuff, now back to my question.

I’ve done everything step by step with Digitalocean’s guides;
I’m running on Debian 11 dist.

Installed LEMP stack, both php7.4fpm and nginx show no errors in console they run without problem but when i’m tryin’ to install Wordpress not just when i try to see php information on my address it downloads instead of executing it. (I’ve lost about 2 plus half days researching to fix the problem but w/o progress so that’s why i created account and i’m posting this question to the community)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Which digitalocean guide are you using?

  • i went w/ debian 10 guides.

    • Double check your Nginx virtual host file, the part about index directive. Make sure you do not have index.html there.

      You should only have index.php. Going by this tutorial (assuming that’s the one you’re following): https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-nginx-mariadb-and-php-on-debian-10

      you should have a line like this

      try_files $uri $uri/ /index.php$is_args$args;

      And then you should have something like this

      index index.php

      If you have index index.html index.php, that might cause issues.

      by Justin Ellingwood
      by Brian Boucheron
      by Erika Heidi
      WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MySQL-based backend with PHP processing. In this guide, we'll focus on getting a WordPress instance set up on a LEMP stack (Linux, Nginx, MariaDB, and PHP) on a Debian 10 server.
      • yes tutorials are ones i’ve went through from start till end plus i’ve applied fixes u wrote into nginx/sites-available/“something” i’m talkin about index .php

        sites-available and sites-enabled are ln’d so applied fix at one will do the same in another.

        but it still downloads

        Don’t want to sound dumb but i was thinkin if the problem is root /var/www/html/“something”

        how should it look like?

        I’ve my website inside html folder; /var/www/html/mydomainname i was thinkin this maybe the reaason? please help me i know the problem is very simple but i just can’t understand and it makes me go crazy (i’m still dilettante in nginx n overall)

        • server {

          listen 443 default_server ssl;
          listen [::]:443;
          include snippets/self-signed.conf;
          include snippets/ssl-params.conf;

          server_name “ ”

          root /var/www/html/“ ”;
          index index.php;

          location / {

          location = /favicon.ico { lognotfound off; accesslog off; }
          location = /robots.txt { log
          notfound off; accesslog off; allow all; }
          location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
          expires max;
          lognotfound off;
          }

          }

          location ~ .php$ {

          tryfiles $uri $uri/ /index.php$isargs$args;
          fastcgisplitpathinfo ^(.+?.php)(|/.*)$;
          fastcgi
          pass unix:/var/run/php/php7.4-fpm.conf.sock
          fastcgiparams SCRIPTFILENAME /var/www/html/“ ”/info.phps$fastcgiscriptname;
          fastcgiparams DOCUMENTROOT /var/www/html/“ ”;

          fastcgiindex index.php;
          include fastcgi
          params;

          location ~ /.ht {
          deny all;
          }

          }
          }

          ssl (ssls come here)
          ssl (ssls come here)

          server {

          listen 80;
          listen [::]:80;

          server_name “ ”

          index index.php

          return 401;
          return 301 https://$servername$requesturi;
          location / {
          try_files $uri $uri/ =404;
          }
          }

          this’s how my VH looks like (i know some of lines might look crazy i did thon of research as mentioned above i lost two and half days and i’m loosing right now please someone help me fix this)

      • any ideas? i just posted my VH config