Posted by ludo1960 on October 11, 2018 at 9:14am
Hi guys,
new to nginx so following blindly like a sheep,
using https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ I created an example.com in /etc/nginx/sites-available/ and symlinked it from sites-enabled and have my drupal 8 in /var/www/example.com. When I go to eample.com I get a 403 but my test.php shows up just fine in example.com/test.php as does my example.com/adminer.php so it's nearly right. Is there something I need to change in nginx.conf to get drupal 8 to work?
PS everything in var/www/ is owned by www-data, so I dont know what else to try?
Thanks
Comments
What do the access and error
What do the access and error logs say when you visit the site root?
How are you specifying what and where the default page is? What does it look like around
try_files $uri /index.php?$query_string;Posting your .conf here may help others help you.
more info
Ok more info:
My cunning plan was to get this installed
https://www.contentacms.org/
All goes well until:
server {
server_name contenta.local.com;
root /var/www/contenta.local.com; ## <-- Your only path reference.
seems my problem is similar to https://groups.drupal.org/node/518846
when i go to http://contenta.local.com i get
No input file specified.
when I go to http://contenta.local.com/web/index.php i see the site but none of the links work. I tried changing the server to /var/www/contents.local.co/web but the result is the same.(with nginx restart)
if I go to http://contenta.local.com/web no index.php shows up, I have to append it to the url, Entries in the location block for D6 and D7 but nothing for drupal 8. What's the magical line of code to get drupal 8 working?
The only lines of I changed in the https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ are the top 2, ie server name and root.
Any ideas guys?
oops forgot to post nginx error log:
2018/10/12 13:56:58 [notice] 8814#8814: signal process started
2018/10/12 13:59:08 [error] 8818#8818: *253 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/?0 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 13:59:08 [error] 8818#8818: *253 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 13:59:09 [error] 8818#8818: *256 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /profiles/contrib/contenta_jsonapi/modules/contenta_enhancements/logo.svg HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 13:59:09 [error] 8818#8818: *256 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 14:01:03 [error] 8818#8818: *296 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com"
2018/10/12 14:02:10 [error] 8818#8818: *306 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/index.php/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 14:02:19 [error] 8818#8818: *306 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/index.php/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 14:09:56 [error] 8818#8818: *376 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /admin/content HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 17:09:11 [error] 643#643: *1017 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com"
2018/10/12 17:09:25 [error] 643#643: *1017 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /web/?0 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
2018/10/12 17:09:25 [error] 643#643: *1017 FastCGI sent in stderr: "Unable to open primary script: /var/www/contenta.local.com/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: contenta.local.com, request: "GET /profiles/contrib/contenta_jsonapi/modules/contenta_enhancements/logo.svg HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "contenta.local.com", referrer: "http://contenta.local.com/web/index.php"
You say the path reference is
You say the path reference is
root /var/www/contenta.local.com;but you navigate to http://contenta.local.com/web/index.php to see the page?Looks like a root mismatch. /web is a subdirectory and where you're index.php is actually found, no?
Maybe it ought to be
root /var/www/contenta.local.com/web;tried that
As I said in my previous post, tried that:
"when I go to http://contenta.local.com/web/index.php i see the site but none of the links work. I tried changing the server to /var/www/contents.local.co/web but the result is the same.(with nginx restart)"
not touched the nginx.conf file, so not sure what to try next.
Progress!
Update:
prepended /web to a couple of locations in the contenta.local.com.conf file, reloaded nginx and cleared caches
now I can log in, result! Still missing the theme tho. Making progress!
If someone who knows more about nginx than my scatter gun approach, now is the time to chip in and update the drupal 8 conf file on nginx web site, so others users can benefit. I switched from apache2 on my little dev box and boy am i glad. The speed difference is obvious.
Following up:
Following up on the so called nginx recipe from:
https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
server {
server_name example.com;
root /var/www/example.com; ## <-- Your only path reference.
Using the above code the webisite throws a "No input file specified. "
When I change it to:
server {
server_name example.com;
root /var/www/example.com/web; ## <-- Your only path reference.
The website is reachable, but all the image paths are all wrong with pre-installed content and hitting the myaccount link results in Access denied, the link http://example.com/index.php/user should be http://example.com/index.php/user/1 so the drupal 8 site is expecting the root to be /var/www/example.com and not /var/www/example.com/web, there has to be something wrong with official nginx drupal recipe. I must be missing a re-write rule or something like that, Any ideas guys?
The official nginx Drupal
The official nginx Drupal recipe won't work for all situations, but that doesn't mean there's something wrong with it.
We don't know enough about what's in your site's .conf file or it's settings.php, or how the site was configured to diagnose the root cause.
I'd recommending trying to set up a local site in a way that matches the expectations of the official nginx recipe. Test with a fresh installation of Drupal 8 using the default build.
When that works, move on to modifying the locations of paths in .conf and testing.
When that works, move on to trying the same with Contenta.
ok started anew, installed
ok started anew, installed drupal 8 as suggested, no problems whatsover. then onto the updated contenta. Started with the official nginx repo, same issues as before, tried https://github.com/contentacms/contenta_docker/blob/master/nginx/conf/dr... for nginx conf but get a 404 not found, here's what i changed to get get sudo nginx -t to run:
https://github.com/contentacms/contenta_docker/blob/master/nginx/conf/drupal.conf
server {
listen 80;
fastcgi_keep_conn on;
root /var/www/contenta.local.com/web;
index index.php;
### Nginx configuration for Drupal 7 and 8. This configuration makes use of
### drush (http:///drupal.org/project/drush) for site maintenance
### and like tasks:
###
### 1. Run the cronjobs.
### 2. Run the DB and code updates: drush up or drush upc followed by
### drush updb to run any DB updates required by the code upgrades
### that were performed.
### 3. Disabling of xmlrpc.xml and update.php: all updates are now
### handled through drush.
## If ssl terminator had ssl, we're passing that on
if ($http_x_forwarded_proto = 'https') {
set $fastcgi_https "on";
}
## rewriting /index.php to / because after https://www.drupal.org/node/2599326
## autocomplete URLs are forced to go to index.php
rewrite ^/index.php / last;
## The 'default' location.
location / {
}
########### Security measures ##########
## Restrict access to the strictly necessary PHP files. Reducing the
## scope for exploits. Handling of PHP code and the Drupal event loop.
location @drupal {
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
### fastcgi_pass ${NGINX_FASTCGI_PASS:-php}:9000; ### Changed to line above
}
## Trying to access private files directly returns a 404.
location /sites/default/files/private/ {
internal;
}
## Disallow access to patches directory.
location ^~ /patches {
deny all;
access_log off;
log_not_found off;
}
## Disallow access to backup directory.
location ^~ /backup {
deny all;
access_log off;
log_not_found off;
}
## Disallow access to vagrant directory.
location ^~ /vagrant {
deny all;
access_log off;
log_not_found off;
}
## Disallow access to /core/vendor.
location ^~ /core/vendor {
deny all;
access_log off;
log_not_found off;
}
## Disallow access to /vendor.
location ^~ /vendor {
deny all;
access_log off;
log_not_found off;
}
## Disable access logs for robots.txt.
location = /robots.txt {
access_log off;
## Add support for the robotstxt module
## http://drupal.org/project/robotstxt.
try_files $uri @drupal;
}
location = /humans.txt {
access_log off;
## Add support for the humanstxt module
## http://drupal.org/project/humanstxt.
try_files $uri @drupal;
}
## Support for favicon. Return an 1x1 transparent GIF if it doesn't
## exist.
location = /favicon.ico {
expires 30d;
try_files /favicon.ico @empty;
}
## Return an in memory 1x1 transparent GIF.
location @empty {
expires 30d;
empty_gif;
}
# Any other attempt to access PHP files does not have access.
location ~* ^.+.php$ {
deny all;
}
### Directives for installing drupal.
location = /install.php {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#### changed to line above: fastcgi_pass ${NGINX_FASTCGI_PASS:-php}:9000;
}
### Directives for installing drupal.
location = /core/install.php {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#### changed to line above fastcgi_pass ${NGINX_FASTCGI_PASS:-php}:9000;
}
}
Sorted
Seems an undocumented settings.local.php needs to placed in the sites folder! All working now! cheers guys!
im using wnmp web server, some links are working
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
events {
# Max value 16384
worker_connections 8192;
# Accept multiple connections
multi_accept on;
}
Settings that affect all server blocks
http {
include php_processes.conf;
include mime.types;
default_type application/octet-stream;
Begin HTTP Server
server {
listen 80; # IPv4
server_name localhost;
}
}
End HTTP Server
Begin HTTPS Server
server {
listen 443 http2 ssl;
server_name localhost;
ssl_certificate cert.pem;
ssl_certificate_key key.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
}
} # End HTTPS Server
}
"Relocated Document Root" impact on apache/nginx root?
Hi
I've been stuck in D6/D7 so when I saw the use of composer and relocated document root, I was excited.
So do we now use
././webroot in the webserver config? Or is D8 smart enough to go down one level? I'm using https://github.com/drupal/recommended-project ...TIA
Gary