Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1130349
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionMy wordpress installation is at /var/www/html/
I have moved the wp-config.php file one level up to /var/www/
and deleted the original file. However, I am getting a 500 error.
Within the wp-config.php there is a line that read:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
I have read that wordpress should automatically read the wp-config if it's only one directory up. I am also using Nginx. Not sure why there is a problem here.
The solution at this thread for specifying the path
Is moving wp-config outside the web root really beneficial?
didn't work. I have tried:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../var/www/wp-config.php');
UPDATE:
I was able to retrieve the following troubleshooting information:
2018/10/29 18:54:09 [error] 10017#10017: *171699 FastCGI sent in stderr:
"PHP message: PHP Warning: require_once(/var/www/wp-config.php): failed to
open stream: Permission denied in /var/www/html/wp-config.php on line 8
PHP message: PHP Fatal error: require_once(): Failed opening required
'/var/www/html/../wp-config.php' (include_path='.:/usr/share/php') in
/var/www/html/wp-config.php on line 8" while reading response header from upstream,
In this instance I defined line 8 as require_once(ABSPATH . '../wp-config.php');
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionMy wordpress installation is at /var/www/html/
I have moved the wp-config.php file one level up to /var/www/
and deleted the original file. However, I am getting a 500 error.
Within the wp-config.php there is a line that read:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
I have read that wordpress should automatically read the wp-config if it's only one directory up. I am also using Nginx. Not sure why there is a problem here.
The solution at this thread for specifying the path
Is moving wp-config outside the web root really beneficial?
didn't work. I have tried:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../var/www/wp-config.php');
UPDATE:
I was able to retrieve the following troubleshooting information:
2018/10/29 18:54:09 [error] 10017#10017: *171699 FastCGI sent in stderr:
"PHP message: PHP Warning: require_once(/var/www/wp-config.php): failed to
open stream: Permission denied in /var/www/html/wp-config.php on line 8
PHP message: PHP Fatal error: require_once(): Failed opening required
'/var/www/html/../wp-config.php' (include_path='.:/usr/share/php') in
/var/www/html/wp-config.php on line 8" while reading response header from upstream,
In this instance I defined line 8 as require_once(ABSPATH . '../wp-config.php');
1 Answer
Reset to default 1In this answer, I assume the following, going by your question:
- Your WordPress site is at
/var/www/html - Your WordPress sites's full config file is at
/var/www/wp-config.php - There is a small file at
/var/www/html/wp-config.phpthat (ideally) will load/var/www/wp-config.php - Your
/var/www/wp-config.phpcontains all the necessary content to run your WordPress site (ie, the code fromwp-config-sample.php, updated as appropriate with your DB information, etc). - There are no other WordPress installations in
/var/www/*
Given all that, your /var/www/html/wp-config.php file should contain the following:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../wp-config.php');
or
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '/var/www/wp-config.php');
From your /var/www/html directory, the path ../var/www/wp-config.php is looking for /var/www/var/www/wp-config.php, which presumably doesn't exist.
Update
The error message: failed to open stream: Permission denied indicates that your webserver can't read the /var/www/wp-config.php file. It will at least need to read the file in order to open it.
I'd recommend asking your host to fix the permissions, or ask them how you can do it yourself. If you're self-hosting on a *nix VPS or something similar, you'll be looking for the chown and/or chmod commands.
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionMy wordpress installation is at /var/www/html/
I have moved the wp-config.php file one level up to /var/www/
and deleted the original file. However, I am getting a 500 error.
Within the wp-config.php there is a line that read:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
I have read that wordpress should automatically read the wp-config if it's only one directory up. I am also using Nginx. Not sure why there is a problem here.
The solution at this thread for specifying the path
Is moving wp-config outside the web root really beneficial?
didn't work. I have tried:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../var/www/wp-config.php');
UPDATE:
I was able to retrieve the following troubleshooting information:
2018/10/29 18:54:09 [error] 10017#10017: *171699 FastCGI sent in stderr:
"PHP message: PHP Warning: require_once(/var/www/wp-config.php): failed to
open stream: Permission denied in /var/www/html/wp-config.php on line 8
PHP message: PHP Fatal error: require_once(): Failed opening required
'/var/www/html/../wp-config.php' (include_path='.:/usr/share/php') in
/var/www/html/wp-config.php on line 8" while reading response header from upstream,
In this instance I defined line 8 as require_once(ABSPATH . '../wp-config.php');
Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?
Closed 6 years ago.
Improve this questionMy wordpress installation is at /var/www/html/
I have moved the wp-config.php file one level up to /var/www/
and deleted the original file. However, I am getting a 500 error.
Within the wp-config.php there is a line that read:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
I have read that wordpress should automatically read the wp-config if it's only one directory up. I am also using Nginx. Not sure why there is a problem here.
The solution at this thread for specifying the path
Is moving wp-config outside the web root really beneficial?
didn't work. I have tried:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../var/www/wp-config.php');
UPDATE:
I was able to retrieve the following troubleshooting information:
2018/10/29 18:54:09 [error] 10017#10017: *171699 FastCGI sent in stderr:
"PHP message: PHP Warning: require_once(/var/www/wp-config.php): failed to
open stream: Permission denied in /var/www/html/wp-config.php on line 8
PHP message: PHP Fatal error: require_once(): Failed opening required
'/var/www/html/../wp-config.php' (include_path='.:/usr/share/php') in
/var/www/html/wp-config.php on line 8" while reading response header from upstream,
In this instance I defined line 8 as require_once(ABSPATH . '../wp-config.php');
- 1 Possible duplicate of Is moving wp-config outside the web root really beneficial? – Pat J Commented Oct 29, 2018 at 14:29
- I have read that thread, but didn't fix the problem. I am only moving wp-config, one directory up which should be automatically detected according to codex – JoaMika Commented Oct 29, 2018 at 15:02
-
Do you still have a
wp-config.phpfile in your WordPress site's root directory? If not, you might need to usedefine( 'ABSPATH', dirname( __FILE__ . '/html/' );, since yourwp-config.phpfile isn't in the WP directory. – Pat J Commented Oct 29, 2018 at 15:37 - According to the other thread, I created a wp-config.php file and put the path to the new wp-config - but still I am getting a 500 error. – JoaMika Commented Oct 29, 2018 at 15:40
- See my answer. tl;dr — I think your path is incorrect, and I offer a couple ways to correct it. – Pat J Commented Oct 29, 2018 at 18:34
1 Answer
Reset to default 1In this answer, I assume the following, going by your question:
- Your WordPress site is at
/var/www/html - Your WordPress sites's full config file is at
/var/www/wp-config.php - There is a small file at
/var/www/html/wp-config.phpthat (ideally) will load/var/www/wp-config.php - Your
/var/www/wp-config.phpcontains all the necessary content to run your WordPress site (ie, the code fromwp-config-sample.php, updated as appropriate with your DB information, etc). - There are no other WordPress installations in
/var/www/*
Given all that, your /var/www/html/wp-config.php file should contain the following:
<?php
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '../wp-config.php');
or
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Location of your WordPress configuration. */
require_once(ABSPATH . '/var/www/wp-config.php');
From your /var/www/html directory, the path ../var/www/wp-config.php is looking for /var/www/var/www/wp-config.php, which presumably doesn't exist.
Update
The error message: failed to open stream: Permission denied indicates that your webserver can't read the /var/www/wp-config.php file. It will at least need to read the file in order to open it.
I'd recommend asking your host to fix the permissions, or ask them how you can do it yourself. If you're self-hosting on a *nix VPS or something similar, you'll be looking for the chown and/or chmod commands.
本文标签: Moving wpconfigphp one level up500 errorNginx
版权声明:本文标题:Moving wp-config.php one level up - 500 error - Nginx 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749223147a2335267.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


wp-config.phpfile in your WordPress site's root directory? If not, you might need to usedefine( 'ABSPATH', dirname( __FILE__ . '/html/' );, since yourwp-config.phpfile isn't in the WP directory. – Pat J Commented Oct 29, 2018 at 15:37