appearing at /wordpress not / (but admin site is correctly /wp-admin) – nginx
-
Hello,
I am attempting to install WP with nginx. I have nearly got it working, except for the following issue:-
The url the blog appears at is https://example.com/wordpress/ instead of https://example.com/.
Further, whilst the front page of the blog renders at /wordpress, the links within point to locations relative to / ; e.g, the ‘1 Comment’ link points to https://example.com/?p=1#comments , which gives 403 Forbidden (the nginx error log shows ‘directory index of “/var/www/wordpress/” is forbidden’).
This all said, the admin site appears correctly at https://example.com/wp-admin/index.php (and https://example.com/wp-admin/install.php was the Installation page).
The readme renders correctly at https://example.com/readme.html
In the Admin Site’s Settings the WordPress address and Site address are both set to ‘https://example.com’. I’ve tried playing around with WP_HOME and WP_SITEURL a bit, but didn’t really get anywhere. If I force them to https://example.com, the blog still appears at https://example.com/wordpress/.
WP is installed into /var/www/wordpress/. The file /var/www/wordpress/wp-config.php is a symlink to /etc/wordpress/config-example.com.php which looks like this:
<?php define('DB_NAME', 'redacted'); define('DB_USER', 'redacted'); define('DB_PASSWORD', 'redacted'); define('DB_HOST', 'localhost'); define('SECRET_KEY', 'redacted'); #This will disable the update notification. define('WP_CORE_UPDATE', false); $table_prefix = 'wp_'; $server = DB_HOST; $loginsql = DB_USER; $passsql = DB_PASSWORD; $base = DB_NAME; $upload_path = "/var/www/wp-uploads/example.com"; $upload_url_path = "https://example.com/wp-uploads"; if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php'); ?>
To create this file, I ran /usr/share/doc/wordpress/examples/setup-mysql but oddly the last two lines (to adjust ABSPATH), were missing and I had to add them manually, or else PHP would crash out saying call to undefined function wp() or is_admin().
My nginx.conf looks like this:
server { listen 80; server_name example.com; root /var/www/wordpress; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { # This is cool because no php is touched for static content try_files $uri $uri/ /index.php; } location ~ \.php$ { #fastcgi_split_path_info ^(/wordpress)(/.*)$; #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi_params; fastcgi_intercept_errors on; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; } }
My fastcgi_params looks like this:
fastcgi_pass unix:/tmp/php.socket; fastcgi_index index.php; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name;
So perhaps I need a rewrite or something? I’m pretty much new to nginx, fastcgi and php so turning to the community for help – any pointers would be greatly appreciated!
Darren
- The topic ‘appearing at /wordpress not / (but admin site is correctly /wp-admin) – nginx’ is closed to new replies.