Hello all,
I seem to be stuck getting nginx to display my YOURLS page. The nginx error.log reads:
*1 directory index of "/var/www/site/" is forbidden, client: IP.IP.IP.IP, server: site.com, request: "GET / HTTP/1.1", host: "site.com"
I've altered some information for privacy.
When I head to my site, I get a 403 message. However, if I enable autoindex in /etc/nginx/sites-available/myYOURLS.com (which is symlinked to /sites-enabled/), everything shows up.
The permissions are 755 on /var/www/site and www-data:www-data owns var/www.
My /sites-available/ config is this:
server {
listen 80;
server_name site.com;
root /var/www/site.com;
#index index.php;
location / {
try_files $uri $uri/ /yourls-loader.php;
#autoindex on;
expires 14d;
add_header Cache-Control 'public';
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm-ubuntu.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Ubuntu 16.04.3
nginx 1.12.1
Most of the above config came from the YOURLS wiki. I've tried explicitly specifying the yourls-loader.php location to no avail. Although I'm honestly not quite sure what the does. I'm sure I'm missing something simple, but this I'm very new to this.
No quite sure where I need to go from here. Thanks in advance!
Duplicate of #2311
Definitely something wrong with #2294, ping @ozh for review.
Testing and everything works perfectly for me, even from scratch and from php cli server.
Weird...
_Edit:_ Some wrong thinking removed. Sorry to close reopen.
+1
On windows, this error is not present.
On Linux, I changed this file
includes/YOURLS/Config/Config.php
here are the changes
public function __construct($config = false) {
$this->set_root(realpath(dirname(dirname(dirname(dirname(__FILE__))))) );
//$this->fix_win32_path(realpath(__DIR__ . '../../../..')) //This does not work on linux but on windows
$this->set_config($config);
}
This now works for me.
Hope this will helps in the bug correction during next update....
@KabataMacharia Good catch, thanks for your feedback! 馃憤
Can you submit a pull request with this change? Thx!
Update.
I pulled the latest update but am still having issues. I stopped nginx and installed Apache2 today. I get a 403 forbidden error on the page and this output in the Apache2 error.log:
AH01276: Cannot serve directory /var/www/site.com/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive
If I go to /admin in a browser, (or anywhere besides the root)m, the index.php displays as plain text.
I've purged and reinstalled PHP as well in case there was an issue there.
sites-enabled config:
<VirtualHost *:80>
ServerName urls.magicmemories.com
DocumentRoot /var/www/site.com
DirectoryIndex index.php index.html
<Directory /var/www/site.com/>
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
.htaccess:
```
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
Options -Indexes
DirectoryIndex index.php index.html
I pulled the latest version today, and am having this issue too:
2017/11/03 19:51:30 [error] 5750#5750: *1990 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'YOURLS\Exceptions\ConfigException' with message 'Cannot find config.php. Please read the readme.html to learn how to install YOURLS' in /var/www/YOURLS/includes/YOURLS/Config/Config.php:89
Stack trace:
#0 /var/www/YOURLS/includes/load-yourls.php(18): YOURLS\Config\Config->find_config()
#1 /var/www/YOURLS/admin/index.php(3): require_once('/var/www/YOURLS...')
#2 {main}
thrown in /var/www/YOURLS/includes/YOURLS/Config/Config.php on line 89" while reading response header from upstream, client: REDACTED, server: ln.demu.red, request: "GET /admin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "ln.demu.red"
I'm also having this same issue
nginx version: nginx/1.13.6
built by gcc 6.3.0 20170516 (Debian 6.3.0-18)
built with OpenSSL 1.1.0f 25 May 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.13.6/debian/debuild-base/nginx-1.13.6=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
$ php7.0 -v
PHP 7.0.19-1 (cli) (built: May 11 2017 14:04:47) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.19-1, Copyright (c) 1999-2017, by Zend Technologies
$ mysql -V
mysql Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Guys, this issue is a mess. There are nginx problems and then "config not found" problems, all mixed.
nginx : is it working with 1.7.2 downloaded from the archive?
Config not found: please try patch from PR 2314
Closing this. Feel free to submit another precise issue with one clearly described problem. Thanks all.
The git pull I did today has restored functionality. Thanks.
Regarding the original issue, I know this is closed but I finally got it working.
I ended up changing:
public function __construct($config = false) {
$this->set_root(realpath(dirname(dirname(dirname(dirname(__FILE__))))) );
//$this->fix_win32_path(realpath(__DIR__ . '../../../..')) //This does not work on linux but on windows
$this->set_config($config);
}
To this:
public function __construct($config = false) {
$this->set_root('/path/to/doc/root');
//$this->fix_win32_path(realpath(__DIR__ . '../../../..')) //This does not work on linux but on windows
$this->set_config($config);
}
Now it's working!
Most helpful comment
On windows, this error is not present.
On Linux, I changed this file
includes/YOURLS/Config/Config.php
here are the changes
This now works for me.
Hope this will helps in the bug correction during next update....