Babaktrad
Babaktrad

Reputation: 184

Nginx does not execute php files on WSL. How can i fix this?

I'm using Ubuntu 18.04 on WSL (Windows Subsystem for Linux) on Windows 10 and i installed Nginx and php7.2-fpm and created a simple php file index.php with echo statement content.
I used sudo php </directory/to/index.php> to test php so it's working correctly. Also, when i start Nginx and navigate to localhost The "Welcome To Nginx!" page is displayed. But, When i navigate to server domain, "This site can’t be reached" is displayed by browser.
How can i fix this problem?

server block configuration file:

server {
    listen       80;

    server_name  site.local;

    access_log  /var/log/nginx/laragadgetstore.com.access.log  main;

    root   /usr/share/nginx/html/site.local;

    index index.php index.html index.htm index.nginx-debian.html;

    error_page   500 502 503 504  /50x.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        fastcgi_buffering off;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
    }

    location ~ /\.ht {
        deny  all;
    }
}

In the nginx.conf, i changed user to www-data and in /etc/hosts file i defined 127.0.0.1 to the server domain. Also, i changed the ownership of conf.d and server domain root directory to the www-data!
Also, in error.log file for Nginx, the last error is:

[emerg] 1837: io_setup() failed (38: Function not implemented)

This error is recorded only when i restart Nginx.
I do not know what to do to get this going!!

Upvotes: 3

Views: 2284

Answers (1)

hasan.in
hasan.in

Reputation: 705

This worked for me. I modified default file under

/etc/nginx/sites-available to use port 8081

Code:

server {
    listen **8081** default_server;
    listen [::]:**8081** default_server;
    // ...
}

Upvotes: 2

Related Questions