6

I installed the latest version of Apache2 / PHP / MYSQL on my PC.

In the directory /src/www/htdocs I created a directory wordpress with all wordpress files.

Then, when I tried to create the wp-config file through the web interface I get this error:

Sorry, but I can't write the `wp-config.php' file.

I tried this command to change the group of /src/www/htdocs/wordpress

chown -R root:root /srv/www/htdocs/wordpress

But it was not working. After some research, I have seen lot of people saying change the group to www-data but I do not see www-data using this command:

cut -d: -f1 /etc/group

Anyone know what I am doing wrong?

  • The user and group that apache run as is set in /etc/apache2/envvars on my debian system. – ctrl-alt-delor Nov 25 '13 at 22:42
  • Look to see who wordpress/apache is running as. On my system it is www-data, I would then have to make sure the files that it needs to change were owned by it (www-data). – ctrl-alt-delor Nov 25 '13 at 22:46
  • Changing owner and group to root can never increase permissions, as root already has permission. – ctrl-alt-delor Nov 25 '13 at 22:49
4

If wp-config.php doesn't exist yet, use:

cp wp-config-sample.php wp-config.php

The group that apache uses is in an Apache config file. Here's how I find in on OS X. for me, the group is _www:

grep ^Group /etc/apache2/httpd.conf

There are 3 permissions groups that Unix/Linux uses - user, group, others. I'm assuming you'll want to remain the user that owns the file. The easiest thing to do is give write permission to the group and others. To do that, use:

 chmod go+w wp-config.php
2

Just change the own of the folder from root to your current user.

sudo chown -R yourcurrentuser:currentgroup /srv/www/htdocs/wordpress
2

First, find out which group the Apache daemon is currently using:

$ cat /etc/apache2/apache2.conf | grep ^Group -B 2
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

OK. This means the group is stored in the APACHE_RUN_GROUP variable:

$ echo ${APACHE_RUN_GROUP}

That variable isn't set in the current environment. Why? I don't really know. But it doesn't matter, because the comment in the Apache config file points us to the file where these variables are defined:

$ cat /etc/apache2/envvars | grep GROUP
export APACHE_RUN_GROUP=www-data

So in my case, the group Apache is running under is www-data. With this info, now change the group of the WordPress directory. In your case:

sudo chgrp -R www-data /src/www/htdocs

The -R flag makes it recursive. Et voilà!

0

Manually create wp-config.php file and past the code which looks like this and re-install the same it will work.

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'landdb');

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

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

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

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

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

/**#@+
 * 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',         '>-QGUoR0nVWO9 rl=XOk}/yn[sZf=[HcZk8@J6Icm/:p#z+4jmJF]n~6m2y?n,TV');
define('SECURE_AUTH_KEY',  '0Sq%,SJ5KP|]wvufKIfn0s4}.=Ln]UuPF8k<Zo]X{]7^4;VT5}q%UITl,!{7w2QM');
define('LOGGED_IN_KEY',    'A[sS*[{ksr}2!qf8G`=&3Z)=vOJGd%X|7k=49s9BZ7k|n7j_WhHPGw*SP.o{?W`#');
define('NONCE_KEY',        '71{xg#3i$Q)L aybW9KPvsRZ&PaV#[[Lc# # 6Q<Mk*7Pi6W(Qh`t$^s>/S:aT>z');
define('AUTH_SALT',        'qa-S$)X)-C(&~:TPD~WQlX,q788*NBCN_:3jGmr@X|@iAOAZ`~igO3>)Z+L[xQQr');
define('SECURE_AUTH_SALT', 'mXE7Glb~H)O<GgB{XMJ.e|~=/t<z~mIQY.Dt=_b)IlUX=$qx@/]w<]bHt1?H(a7 ');
define('LOGGED_IN_SALT',   '=0T`7(nbT&n`%eOx0[fk%)v_ncoZf +Br&<Wi3N> Vy0XD/)w8?3xw2c9LOKlSR-');
define('NONCE_SALT',       'rvK~}( 5kjw4Wd<vgFLu5eCp%n03 e-&;5mL5J,aQ.M*RY{7n8GtoN}0aj-jzXC<');

/**#@-*/

/**
 * 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_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', false);

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

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

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

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.