How can you modify nginx config file to work 2 projects on different platform?

Viewed 36

I have a node project hosted with Nginx on an AWS server(Ubuntu). Now I want to deploy a PHP project in a folder of that project. Is it possible to do so?

Example: My node project is on the domain - dummydomain.com I want to host a PHP project on - dummydomain.com/testing/

This is my config file.

server {

    listen 80 default_server;


    server_name dummydomain.com;


    return 301 https://$host$request_uri;

}
server {
        listen 443;
        server_name dummydomain.com;

        root /var/www/html;

        index index.html index.htm index.php;

        #this is where node project runs
        location / {
                proxy_set_header   X-Forwarded-For $remote_addr;
                proxy_set_header   Host $http_host;
                proxy_pass         "http://127.0.0.1:5000";
        }
        # I want to run PHP project in this directive
        location /testing {
                #alias /var/www/html;
                #index index.html index.php;
                try_files $uri $uri/ /index.php$is_args$args;
        }
        location ~ \.php$ {
                fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        }
        location ~ /\.ht {
                deny all;
        }
}

By these settings, I have achieved to run dummydomain.com/testing/ but can't run dummydomain.com/testing/index.php or dummydomain.com/testing/testing.php or any sort of PHP file.

0 Answers
Related