Unable to create directory wp-content/uploads in Wordpress - wordpress

I created php files for my plugin and added them to myplugin folder. Then I zipped myplugin folder as myplugin.zip. In Admin Panel of Wordpress I wanted to install my plugin to wordpress. I choosed this zip file and clicked to Install "Now button". Then Wordpress gave an error:
Unable to create directory wp-content/uploads/2013/05. Is its parent directory writable by the server?
What is the problem and how can I solve it? My OS is Linux and I use XAMPP server in my machine.

In your terminal, navigate to the wp-content folder and then run:
chmod -R 0744 plugins
That will set the folder and its subfolders to read/write/execute for you and read for everyone else.
Edit As suggested in the comments, check this out: codex.wordpress.org/Changing_File_Permissions
Alternatively you can just unzip them yourself and save them into this folder:
/wp-content/plugins/name-of-theplugin
Then you can just activate the plugin from the admin page.

I am not entirely familiar with XAMPP but it should be run as a user. Most likely your own windows account. You may try this:
Select the folder wp-content and right click -> properties. then go to Security Tab. There check to see if the User (i.e. you) has write+ modify permission.
Check what is XAMPP server running as, the folder above must have the permissions for the same user.
Double check the "general" tab on the wp-content folder and check the "Attributes" section. Make sure "Read Only is unchecked. If you are changing it, windows will prompt for whether to apply to subfolder. Say "yes".
. Or run XAMPP at Administrator and skip the above step .(assuming it is not production / public internet facing server).

I had this problem yesterday, I solved it by uninstalling the Wordpress module and installing it again as root from the terminal.
I thought if I run the installation wizard as I was logged as root was enough, but it wasn't.
These are the steps for MacOS:
Uninstall wordpress module. Be sure the folder is empty.
Mount the wordpress disk image
cd /volumes/nameOfWordpressModule image
sudo bitnami wordpress module.app/Contents/MacOS/installerbuilder.sh
I recommend you to list the items so you can write exactly the name of the image and app.
Hope it helps!

navigate to your main project folder and run the following:
chmod -R 0777 wp-content

in case of MAC run
sudo chmod -R 777 /Applications/XAMPP/htdocs/

Related

Wordpress Plugins Couldn't Update: Could not create directory

Good day! Why is it that I am not able to update my plugins in my Wordpress Website.
In my FTP File I have already set my plugins folder to 755 then configured my wp-contents to 755. In my wordpress Site Health, this is what is written in File Permission
The main WordPress directory Writable
The wp-content directory Writable
The uploads directory Writable
The plugins directory Writable
The themes directory Writable
I have done everything written in this site and still I can't update any of my plugins. I don't know what is wrong anymore or what should I do.
I am using CWP, with WordPress 5.5.1 and PHP version 7.4.10
One way to solve this problem, trying to change the FTP permissions by the “wp-config.php” file.
There're some steps to fix “Installation failed, could not create directory.” From your web hosting account, open the “File Manager”. Within the root folder, locate the “wp-config.php” file.
In your “wp-config.php” file, enter the following passage of code.
NOTE: Replace the information in brackets with your information.
define(‘FS_METHOD’, ‘ftpext’);
define(‘FTP_BASE’, ‘/pathtorootofyourblog/’);
define(‘FTP_USER’, ‘ftpusername’);
define(‘FTP_PASS’, ‘ftppassword’);
define(‘FTP_HOST’, ‘yoursite.com’);
define(‘FTP_SSL’, false);
Save the “wp-config.php” file.
Return to your dashboard and try to install the plugin or upgrade once again. This time, it should be done without any problems.

(Using shared hosting for Wordpress in Hostgator) Installation failed: Could not create directory

Can somebody help me, how should i create a a directory for plugins, there's already a folder created in Hostgator's Cpanel "Public_html>Wp_content>plugins".
But still if i install any plugin, this error pop ups "Installation failed: Could not create directory." please help, Thank You in advance
You just need to give the permission to the folder.
When you installing any plugin it will uploaded to /wp-content/plugins directory.
Now there is three option to achieve this.
1) connect ssh and go to desire path and run chmod command
Chmod 777 -Rf /var/www/html/wp-content/plugins
2) Open file manager from cpanel and go desire path and select folder and give the permission
3) creat a script which give me the folder permission. You can get that script on google
Here is one of the link :
https://gist.github.com/jasperf/5755794

How to upload WordPress child theme to XAMPP + Bitnami + Mac OS?

Everything was going so well: installed XAMPP on Mac (OS 10.10.2). Installed Bitnami WordPress module. Imported existing WordPress site (this site is already live). Then imported/installed the theme I want to modify. All good up to that point.
Now I want to create a child theme. Following the instructions from Themify, which are great. BUT: I can't open the htdocs directory within the wordpress dir that was installed by the Bitnami module. No permissions.
There's a help page, but it's not helping me. Reason 1: I open FileZilla, I FTP to localhost, but the wordpress dir is nowhere to be found there. Reason 2: I try to follow their sudo chown instructions but the path is not valid for me. I tried:
$ sudo chown daemon:daemon Applications/XAMPP/xamppfiles/apps/wordpress/htdocs
... but no luck. "No such file or directory." I can find this folder in the Finder (see screencap), but I can't seem to access it from the command line. (Is that because XAMPP is in the Applications directory?)
In case it's not obvious, I am doing all this to muck around with my child theme offline. But I can't get my child theme folder into the wp-content/themes folder, because I can't FTP or access the folder directly through the Finder.
I was able to change permissions through the Mac "Get Info" panel. Doh!!
"Get Info" panel, unlocked
See screencap.
Try and put a Leading slash at the front of the directory listing so run this instead:
sudo chown daemon:daemon /Applications/XAMPP/xamppfiles/apps/wordpress/htdocs
Just go to /Applications/XAMPP/xamppfiles/htdocs/mysite/wp-content/themes/your-child theme and set permission of your child theme folder to writable to everyone.

Unable to locate WordPress Content directory (wp-content) - localhost on Mac

My configuration
- Mac OS 10.9
- XAMPP
- ProFTPD
- WordPress 3.8.3
Unlike most other posts on the internet for the same problem, I was not on some hosting website rather on a locally hosted instance on Mac.Everytime I tried to access the site, I got the error that the server was unable to locate the wp-content directory.
In macOS httpd server is executed as user "daemon".
Therefore you need to change ownership of htdocs to daemon user:
$ sudo chown -R daemon:daemon htdocs
After a few hours of tweaking around, I did the following
Delete previous installation of WordPress and install fresh copy
Set the permissions on wp-content directory via termina shell using the command chmod -R 777 wp-content. This sets the permission of all underlying files and folders as well
I went to this link and used the solution provided here - http://wordpress.org/support/topic/auto-update-failure-in-wordpress-27?replies=17#post-982487
Essentially, I added the following line at the bottom of my wp-config file - putenv('TMPDIR=' . ini_get('upload_tmp_dir'));
Vola!! it worked and I can now focus on more important things.

Can I install/update WordPress plugins without providing FTP access?

I am using WordPress on my live server which only uses SFTP using an SSH key.
I want to install and upgrade plugins, but it appears that you are required to enter your FTP login to install the plugins. Is there a way to install and upgrade plugins by manually uploading the files instead of having WordPress handle the entire process?
WordPress will only prompt you for your FTP connection information while trying to install plugins or a WordPress update if it cannot write to /wp-content directly. Otherwise, if your web server has write access to the necessary files, it will take care of the updates and installation automatically. This method does not require you to have FTP/SFTP or SSH access, but it does require your to have specific file permissions set up on your webserver.
It will try various methods in order, and fall back on FTP if Direct and SSH methods are unavailable.
https://github.com/WordPress/WordPress/blob/4.2.2/wp-admin/includes/file.php#L912
WordPress will try to write a temporary file to your /wp-content directory. If this succeeds, it compares the ownership of the file with its own uid, and if there is a match it will allow you to use the 'direct' method of installing plugins, themes, or updates.
Now, if for some reason you do not want to rely on the automatic check for which filesystem method to use, you can define a constant, 'FS_METHOD' in your wp-config.php file, that is either 'direct', 'ssh', 'ftpext' or 'ftpsockets' and it will use that method. Keep in mind that if you set this to 'direct', but your web user (the username under which your web server runs) does not have proper write permissions, you will receive an error.
In summary, if you do not want to (or you cannot) change permissions on wp-content so your web server has write permissions, then add this to your wp-config.php file:
define('FS_METHOD', 'direct');
Permissions explained here:
http://codex.wordpress.org/Updating_WordPress#Automatic_Update
http://codex.wordpress.org/Changing_File_Permissions
As stated before none of the perm fixes work anymore. You need to change the perms accordingly AND put the following in your wp-config.php:
define('FS_METHOD', 'direct');
Just wanted to add that you must NEVER set the wp-content permission or permission of any folder to 777.
This is what I had to do to:
1) I set the ownership of the wordpress folder (recursively) to the apache user, like so:
# chown -R apache wordpress/
2) I changed the group ownership of the wordpress folder (recursively) to the apache group, like so:
# chgrp -R apache wordpress/
3) give owner full privilege to the directory, like so:
# chmod u+wrx wordpress/*
And that did the job. My wp-content folder has 755 permissions, btw.
TL;DR version:
# chown -R apache:apache wordpress
# chmod u+wrx wordpress/*
In wp-config.php add define('FS_METHOD', 'direct');
Make server writable the directories wp-content/, wp-content/plugins/.
Install the plugin (copy the plugin dir into the wp-content/plugins dir).
Worked on version 3.2.1
open wp-config.php file and add the following line:
define('FS_METHOD', 'direct');
this is working for me ...Thanks
Just a quick change to wp-config.php
define('FS_METHOD','direct');
That’s it, enjoy your wordpress updates without ftp!
Alternate Method:
There are hosts out there that will prevent this method from working
to ease your WordPress updating. Fortunately, there is another way to
keep this pest from prompting you for your FTP user name and password.
Again, after the MYSQL login declarations in your wp-config.php file,
add the following:
define("FTP_HOST", "localhost");
define("FTP_USER", "yourftpusername");
define("FTP_PASS", "yourftppassword");
Change from php_mod to fastcgi with cgi & SuEXEC enabled (ISPConfig users). Works for me.
If don't work, try to change wp-content to 775 as root or sudo user:
chmod -R 775 ./wp-content
Then Add to wp-config.php:
define('FS_METHOD', 'direct');
Good Luck
In order to enable the use of SSH2 for your updates and theme uploads, you have to generate your SSH keys and have the PHP SSH module installed. Then WordPress will detect that you have SSH2 available and you'll see a different option (SSH2) displayed when doing an upload/upgrade.
1.) Make sure you have the PHP module installed for debian it is:
sudo apt-get install libssh2-php
2.) Generate SSH keys, adding a passphrase is optional:
ssh-keygen
cd ~/.ssh
cp id_rsa.pub authorized_keys
3.) Change the permission so that WordPress can access those keys:
cd ~
chmod 755 .ssh
chmod 644 .ssh/*
Now you'll get the SSH2 option when doing an upload/upgrade/plugin.
4.) For added ease you can setup the defaults in your wp-config.php and this will pre-populate the SSH credentials in the WordPress upload window.
define('FTP_PUBKEY','/home/<user>/.ssh/id_rsa.pub');
define('FTP_PRIKEY','/home/<user>/.ssh/id_rsa');
define('FTP_USER','<user>');
define('FTP_PASS','passphrase');
define('FTP_HOST','domain.com');
The 'passphrase' is optional, if you don't setup a passphrase during ssh-kengen; then don't add it in wp-config.php
This solved my issue. And I didn't have to do the chown at all. But I have seen this method referenced in other places.
References:
http://wp.tutsplus.com/articles/tips-articles/quick-tip-upgrade-your-wordpress-site-via-ssh/
http://codex.wordpress.org/Editing_wp-config.php#Enabling_SSH_Upgrade_Access
Usually you can just upload your plugin to the wp-content\plugins directory. If you don't have access to this directory via SFTP I'm afraid you may be stuck.
You can get it very easily by typing the following command on command promt
sudo chown -R www-data:www-data your_folder_name
or copy & paste the following code in your wp-config.php file.
define('FS_METHOD', 'direct');
Where "your_folder_name" is the folder where your WordPress is installed inside this folder.
If you're on Ubuntu, a quick solution that worked for me is giving ownership to the Apache user (www-data by default) like so:
cd your_wordpress_directory
sudo chown -R www-data wp-content
sudo chmod -R 755 wp-content
Execute the following code in terminal
sudo chown -R www-data /var/www
For further detail visit
Wordpress on Ubuntu install plugins without FTP access
Add the following code to wp-config
define('FS_METHOD', 'direct');
FS_METHOD forces the filesystem method. It should only be direct, ssh2, ftpext, or ftpsockets. Generally, you should only change this if you are experiencing update problems. If you change it and it doesn't help, change it back/remove it. Under most circumstances, setting it to 'ftpsockets' will work if the automatically chosen method does not.
(Primary Preference) "direct" forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.
(Secondary Preference) "ssh2" is to force the usage of the SSH PHP Extension if installed
(3rd Preference) "ftpext" is to force the usage of the FTP PHP Extension for FTP Access, and finally
(4th Preference) "ftpsockets" utilises the PHP Sockets Class for FTP Access
For more information visit: http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants
WordPress 2.7 lets you upload a zip file directly (there's a link at the bottom of the plugins page) -- no FTP access needed. This is a new feature in 2.7, and it works for plugins only (not themes yet).
Please add define('FS_METHOD','direct'); in wp-config.php
Resurrecting an old thread, but there's a fantastic new plugin called SSH SFTP Updater Support that adds in SFTP capabilities without needing to edit your wp-config.php file. Also, Wordpress's SFTP implementation relies on some somewhat obscure PHP modules that are often not enabled on servers; this plugin packages a different PHP SFTP plugin so you don't have to configure anything on the Apache side.
I had run into tons of problems getting SFTP support to work - this plugin solved all of them and is just fantastic.
The answer from stereointeractive covers all the options. Just wanted to mention an alternate way of using FTP. I'm guessing that the reason you are not allowing FTP access is for security. One way to address those security concerns is to run your FTP server listening only on 127.0.0.1
This allows you to use FTP from inside WordPress and you will be able to install plugins while not exposing it to the rest of the world. This can also be applied to other popular web applications such as Joomla! and Drupal. This is what we do with our BitNami appliances and cloud servers and works quite well.
I also recommend the SSH SFTP Updater Support plugin. Just solved all my problems too...especially in regards to getting plugins to delete through the admin. Just install it in the usual way, and the next time you're prompted by WordPress for FTP details, there'll be extra fields for you to copy/paste your private SSH key or upload your PEM file.
Only problem I have is in getting it to remember the key (tried both methods). Don't like the idea of having to find and enter it every time I need to delete a plugin. But at least it's a solid fix for now.
Yes, directly install the plugin in WordPress.
Copy the plugin folder and paste in WordPress plugin folder.
go to admin side (/test/wp-admin) then after go to on the plugin link and check the name of the plugin.
Activate the plugin so Install the plugin easily.
other Option
create the zip file for the plugin code.
go to admin side (/test/wp-admin) then after go to on the plugin link and then click on the add new then browse the plugin zip folder and install the plugin then come out the option activate plugin so so do activate plugin and activate plugin.
I saw a lot of people recommending to set permission to 777. I had same problem like 2 days ago and all I did was, add this to wp-content
define('FS_METHOD', 'direct');
and
set permission to 775 for plugin folder
This solved my problem of asking FTP access login/password.
Before that, I had to add plugin manually by adding .zip file to plugin folder and then go to wp-admin/plugins and had to installed it.
It is possible to use SFTP or SSH to auto update Plugins in WordPress, but you need to have ssh2 pecl extension. You can find out how to do it, using the following tutorial
We use SFTP with SSH (on both our development and live servers), and I have tried (not too hard though) to use the WordPress upload feature. I agree with Toby, upload your plugin(s) to the wp-content/plugins directory and then activate them from there.
Try this
1) In the wp-config.php add define('FS_METHOD', 'direct');
2) Set the wp-content directory to 777 for writable.
3) Now install the plugin.
Try this Check whether the correct permission is given to wp-content folder.
Edit the wp-config.php add the following line
define('FS_METHOD', 'direct');
chmod the "wp-content" directory to www-data for full access.
Now try installing the plugin.
Yes you can do it.
You need to add
define('METHOD','direct');
in your wpconfig.
But this method won't be preferable because it has security voilances.
Thanks,
setting up a ftp or even an SFTP connection or chmod 777 are bad ways to go for anything other than a local environment. Opening even an SFTP method introduces more security risks that are not needed.
what is needed is a writeable permission to /wp-content/uploads & /wp-content/plugins/ by the owner of those directories. (linux ls -la will show you ownership).
Default apache user that runs is www-data.
chmod 777 allows any user on the machine to edit those file, not just the apache/php thread user.
SFTP if you are not already using it, will introduce another point of possible failure from an external source. Whereas you only need access by the local user running the apache/php process to complete the objective.
Didn't see anyone making these points, so I thought I would offer this info to help with our constant WP security issues online.
Method 1:
You can set this:
1. in wp-config.php you need to write this lines.
define('FS_METHOD', 'direct');
Note: put this after define( 'DB_CHARSET', 'utf8mb4' ).
set wp-content permission or permission recursively 775 full permission
you can give it via filezilla. write click on directory > permissions> check read-write and execute and also check Recurse into subdirectories
Method 2:
or You can also set this
define("FTP_HOST", "localhost");
define("FTP_USER", "yourftpusername");
define("FTP_PASS", "yourftppassword");
Here is a simple method.
Execute following commands.
This will enable your mod_rewrite module for Apache
$sudo a2enmod rewrite
This Command will change the owner of the folder to www-data
$sudo chown -R www-data [Wordpress Folder Location]
After You executing above commands you can install any themes without FTP.
You can add following in wp-config.php
define('METHOD','direct');
Here is a youtube video that explaining how to do it. https://youtu.be/pq4QRp4427c
The best way to install plugin using SSH is WPCLI.
Note that, SSH access is mandatory to use WP CLI commands. Before using it check whether the WP CLI is installed at your hosting server or machine.
How to check : wp --version [ It will show the wp cli version installed ]
If not installed, how to install it :
Before installing WP-CLI, please make sure the environment meets the minimum requirements:
UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment.
PHP 5.4 or later
WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality
If above points satisfied, please follow the steps : Reference URL : WPCLI
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
[ download the wpcli phar ]
php wp-cli.phar --info [ check whether the phar file is working ]
chmod +x wp-cli.phar [ change permission ]
sudo mv wp-cli.phar /usr/local/bin/wp [ move to global folder ]
wp --info [ to check the installation ]
Now WP CLI is ready to install.
Now you can install any plugin that is available in WordPress.org by using the following commands :
wp install plugin plugin-slug
wp delete plugin plugin-slug
wp deactivate plugin plugin-slug
NOTE : wp cli can install only those plugin which is available in wordpress.org

Resources