2

I have set up WordPress on my computer, installed in /var/www/localhost/htdocs and eventually got the admin page and entered a username and a password.

This is my wp-config.php (I have taken out the MySQL password and the longer comments):

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'root' );

/** MySQL database password */
define( 'DB_PASSWORD', '?xxx?' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/** MySQL socket */
define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );
/**
/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

define( 'WP_DEBUG', true );
define('WP_DEBUG_LOG',true);

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
        define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

I can login using http://localhost/wp-login.php but after that I get "403 Forbidden" -- I have set debug on in the hope of further information but I cannot find a log file.

I hope you can help me... (sorry, can't find an appropriate tag)

2
  • the log file is in wp-content/debug.log - but this will be empty if there are no PHP errors, which you would expect on a fresh WP install – Q Studio Dec 23 '20 at 20:17
  • 1
    Also, check your webserver's logs. They may provide some insight into your problem. – Pat J Dec 24 '20 at 1:11
0

A 403 error is usually caused by either a plugin, a corrupt .htaccess file (this isn't the case since the installation is local) or wrong permission on crucial files. If you are running Linux, try to run this in your local shell:

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
5
  • Thank you for your suggestion -- I thought all the directories were drwxr-xr-x and all the files were -rw-r--r-- so I checked and found to my surprise and horror!! that /var/www was drwxr-xr-x 3 cherokee root 4096 Jun 29 2019 www/ How this happened I have no idea. Thank you for leading me in the right direction. – Chris Dec 24 '20 at 9:41
  • Glad that it worked out. Can you please upvote my answer or set it as a solution? – karl Dec 24 '20 at 11:36
  • I changed 'cherokee' to 'root' and it made no difference. In the nginx error log that @Pat suggested I look at, I found directory index of "/var/www/localhost/htdocs/" is forbidden, . drwxr-xr-x 5 root root 4096 Jun 9 2014 htdocs/ should be OK, I ran $ find -type d|xargs ls -dl|egrep -v '^drwxr-xr-x' and $ find -type d|xargs ls -dl|egrep -v 'root root' getting no output so all directories have owner/group 'root' and are searchable by 'other' as well. This is quite beyond my understanding... – Chris Dec 24 '20 at 14:57
  • Unfortunately, this is beyond my understanding as well. – karl Dec 24 '20 at 15:03
  • Thank you @Karl, at least I'm not alone... and, several years ago, I had it working... – Chris Dec 24 '20 at 15:41
0

Try to change permission of wordpress folder in localhost to 755 this can helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.