php - nginx error: "No input file specified" when website in subdirectory
Get the solution ↓↓↓I have been trying to search about this problem a few hours but none of the solutions seem to work in my case.
I have installed joomla in my nginx server on raspbian for testing purposes. The directory is in /var/www/joomla.
The site works if I change the root directory from /etc/nginx/sites-available to /var/www/joomla, but if I want my joomla site accessed from http://www.example.com/joomla, it won't work. I can get to the joomla homepage, but if I click some link from the homepage (for example I have a contact form which address is http://www.example.com/joomla/index.php/contact) I get "No input file specified error".
Here is my config from /etc/nginx/sites-available/site:
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
I read this error may have something to do with fastcgi_param SCRIPT_FILENAME, but I didn't figure out what I should edit and from where.
Thank you!
Answer
Solution:
Yes! I got it working. Thanks to Joe Niland who told the solution.
I actually tried it once but I may have missed the '/' before the joomla/index.php....
The working /etc/nginx/sites-available/site configuration is now:
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /joomla/index.php?q=$request_uri;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Answer
Solution:
Look below for config setting
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$request_uri$args;
}
location ~ \.php$ {
root /var/www;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: uncaught error: call to undefined function mysqli_connect()
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.