New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
You're probably looking for the
try_files
directive. You don't needmod_rewrite
for it.http://winginx.com/en/htaccess
Tried that not able to figure it out.
the first example just rewrites everything to /public/, so when you configure nginx, just set the
root /path/to/public/
this is the second one that should be
rewrite ^/(.)$ /index.php break;
So all together, after server{ should look like;
location / {
root /path/to/public;
rewrite ^/(.)$ /index.php break;
location ~* ^.+.(jpg|jpeg|gif|css|js)$ {
root /path/to/public;
}
}
Edit: This isn't formatting nicely above, Pastebin: http://pastebin.com/YNHVQ4Kb
Like others have said, you really just need to set the public directory as your root. Then use:
try_files $uri $uri/ index.php;
e: duplicate post
I got the first part solved only 1 thing is left im not able to access assets folder in public folder for some reason its throwing a 404 error.
server {
listen 80;
server_name some.domain;
root /usr/share/nginx/html/public;
index index.php;
location / {
rewrite ^/(.)$ /index.php break;
include fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /assets {
try_files $uri $uri/ $document_root;
}
}
Edit: Solved it. So now please tell me if the above way is correct or if I should make any changes.
If all you're even going to do is re-direct to index.php in that location block then maybe get rid of the rewrite?
Also you could configure FPM to listen on a socket.
location / { include fastcgi_params; fastcgi_intercept_errors off; fastcgi_pass /path/to/unix/socket; fastcgi_param SCRIPT_FILENAME /path/to/index.php; }
Since you're here could you tell why nginx can't open ports above 1024 ?
Not sure on that one. It usually can. Anything in the logs etc? Firewall, selinux?
You mean below 1024, right? That's because you need elevated (read: root) permissions in order to open a port lower than that.
http://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user
This is the most simple option.
ill check
My problem is quite opposite to that post he's not able to open anything except port 80 81 or 8080 for nginx
That's err.. Odd.. Are you sure the port you're trying to bind to isn't occupied by an existing service or blocked by your firewall?
iptables turned off all ports freed idk what the fuck is wrong and beating my head for past few hours ( successfully introduced phpseclib into the framework in meantime ).
Would you mind pastebinning your Nginx config?
server {
listen 80;
server_name rcp.readydedi.com;
root /usr/share/nginx/html/public;
error_log /var/log/nginx/php_error.log error;
index index.php;
location / {
rewrite ^/(.)$ /index.php break;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_intercept_errors off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /assets {
try_files $uri $uri/ $document_root;
}
}
server {
listen 81;
server_name default_server;
root /usr/share/nginx/html/public/phpma;
index index.php;
location / {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_intercept_errors off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /themes {
try_files $uri $uri/ $document_root;
}
}
What was the error you were hit with?
When I change port to anything for eg 2081 or 2082 or any other port says nginx bind failed and error is permission denied
SELinux?
Disabled, setenforce=0 also done
So anyone else can suggest anything regarding to ports issue
Try this one. Never had any problems with assigning ports to nginx.
Try and see if there's an app using that port.
I've already checked theres no app using the port im trying to assign, check this
2015/09/27 04:41:07 [emerg] 3781#0: bind() to 0.0.0.0:2080 failed (13: Permission denied)
Maybe this can help: http://serverfault.com/a/566320
-
If the above doesn't help, try setting CAP_NET_BIND_SERVICE to the nginx binary, something like:
(fix the nginx path, naturally).
Edit #1: fixed the link.
Edit #2: added info about setcap
Try not use "default_server"
Yea I know its just home server so just used it so I can access over ip also.
On some nginx mainline version, the "default_server" can cause problem if you have multiple blocks or conflict with other nginx module you compile from scratch, you need to understand the server order if use default_server.
If that happened in your case, all traffic will through from port 81