Welcome! Log In Create A New Profile

Advanced

php and nginx

Posted by destramic 
php and nginx
August 04, 2015 03:17PM
i've decided to give nginx a whirl instead of apache...but im having a few problems running php on it.

here is my config file

-----------------------------------------------------
server {
listen 80;
server_name development;

#charset koi8-r;

access_log logs/error.log main;

location / {
root C:\Users\Ricky\Desktop\www;
index index.php;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root C:\Users\Ricky\Desktop\www;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php(/.*)?$ {
root C:\Users\Ricky\Desktop\www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:\Users\Ricky\Desktop\www$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
-----------------------------------------

then i used

---------------------------------------

@ECHO OFF
start c:\nginx\nginx.exe
start c:\php\5.6.11\php-cgi.exe -b 127.0.0.1:9000 -c c:\php\5.6.11\php.ini
ping 127.0.0.1 -n 1>NUL
echo starting nginx
echo .
echo ..
echo ...
ping 127.0.0.1 >NUL
EXIT

-----------------------------------------

to start nginx and php but when accessing http://localhost nothing is displayed.

where am i going wrong please guys?

thank you
Re: php and nginx
August 04, 2015 04:37PM
Use / not \ in .conf file.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: php and nginx
August 05, 2015 07:02AM
well i was getting the error:

2015/08/04 20:22:21 [emerg] 5420#4628: "server" directive is not allowed here in C:\nginx/conf/nginx.conf:1

so i refereed back to the default config and altered for php.

here is my config file...when you said use / instead of \ then i guess your on about document root....although i have no errors in my log i still cant display a simple php file or html for that matter.


----------------------------------


#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 8080;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root C:/Users/Ricky/Desktop/www;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:8080
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php(/.*)?$ {
root C:/Users/Ricky/Desktop/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:\Users\Ricky\Desktop\www$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}


-----------------------


thank you
Re: php and nginx
August 05, 2015 09:25AM
Is nginx running at all? if so then you should have entries in the logfiles.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: php and nginx
August 05, 2015 03:02PM
nothing in log or access when trying to access today. localhost just shows a blank page.

this is used to start nginx...also i've tried just clicking on nginx.exe...what am i doing wrong

@ECHO OFF
start c:\nginx\nginx.exe
start c:\php\5.6.11\php-cgi.exe -b 127.0.0.1:9000 -c c:\php\5.6.11\php.ini
ping 127.0.0.1 -n 1>NUL
echo starting nginx
echo .
echo ..
echo ...
ping 127.0.0.1 >NUL
EXIT
Re: php and nginx
August 05, 2015 03:50PM
Open a cmd prompt and start nginx from there so you can see any messages.
Use taskmanager to see if anything is running, make sure nothing(nginx) is before starting nginx.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: php and nginx
August 05, 2015 04:13PM
ok i closed nginx from task manager.

and opened cmd -> start nginx

2 nginx programs appear my task manager with still a blank page on localhost =/
Re: php and nginx
August 05, 2015 05:35PM
Are there any files in "[root] C:/Users/Ricky/Desktop/www" ?

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: php and nginx
August 06, 2015 12:53PM
yep...it's where all my files are :(
Re: php and nginx
August 06, 2015 02:55PM
Are you sure nginx is listening on port 80?
The logfiles must say something, check them again.
Try a simple nginx.conf file, strip anything you don't need at the moment.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: php and nginx
August 06, 2015 04:48PM
it was down to the port....http://127.0.0.1:8080/ worked like a charm....sorry!

thank you for your help
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready