Nginx server configuration problem

pasansnoop

Well-known member
  • Sep 13, 2008
    9,092
    1
    6,967
    113
    TrapHouse
    machan is there anybody who knows how to configure nginx to use php on a server?
    after doing everything, I get '502 Bad Gateway' error from the server :oo:
    i'm stuck for a day troubleshooting the error but couldn't find any..

    this is the guide I followed> https://www.techsupportpk.com/2019/04/how-to-set-up-lemp-stack-ubuntu-1904.html

    can you spot any fault in this config? (which I've linked to /etc/nginx/sites-enabled/)

    NGINX:
    server {
            listen 80;
            root /var/www/html;
            index index.php index.html index.htm index.nginx-debian.html;
            server_name localhost;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
            }
    
            location ~ /\.ht {
                    deny all;
            }
    }
     
    • Like
    Reactions: kinkon

    pasansnoop

    Well-known member
  • Sep 13, 2008
    9,092
    1
    6,967
    113
    TrapHouse
    do you have any idea what you are doing ?
    If you just want a working PHP environment perhaps look at getting a working LAMP stack on that server.
    Ubuntu natively supports LAMP and can be installed from apt

    Or install a control panel such as Virtualmin, which will also give you LAMP and the ability to host multiple domains and control it via a browser based control panel
    look at my first post mate..
    i've already installed LEMP stack on ubuntu and the problem is php not working on it

    okath balala try kala machan..
    eth oya widiyata changes kalama file not found kiyala enne browser eke :baffled:
    ------ Post added on Aug 5, 2022 at 11:09 AM
     

    kosandpol

    Well-known member
  • Jun 10, 2008
    45,329
    1,492
    113
    look at my first post mate..
    i've already installed LEMP stack on ubuntu and the problem is php not working on it


    okath balala try kala machan..
    eth oya widiyata changes kalama file not found kiyala enne browser eke :baffled:
    ------ Post added on Aug 5, 2022 at 11:09 AM
    I'm not referring to LEMP, if you just need a working PHP environment, install LAMP - Linux, APACHE, MySQL & PHP on that server instead of messing around with Nginx.
     
    • Like
    Reactions: pasansnoop