Wordpress localhost ftp - php

I have wordpress running on my localhost on mac Lion.
Everytime I try to install or delete plugins it asks me for hostname, ftp username and ftp password.
I configured my localhost to 127.0.0.1, but I have never configured the ftp username and password for my localhost. How can I get which user and password it's by default?
I have tried almost every user and pass I have on mysql, my osx admin, etc. with no results.
Any ideas?

Update as mentioned by Chaudhry Waqas in comments it might be sufficient to just add define('FS_METHOD', 'direct'); to wp-config.php, so please try this first as it's safer not to change access rights if not necessary
WARNING: only do this on your local computer, it's a huge security risk on a public installation!
I haven't tried it but as mentioned by #misterfancypants comment, changing those settings only for wp-content/plugins/ should be sufficient
updated to incorporate this info
This one worked for me
$ cd /Users/<username>/Sites
# (wordpress = name of the directory, change as needed)
$ sudo chown -R :_www wordpress
$ sudo chmod -R g+w wordpress
and then add following in wp-config.php
define('FS_METHOD', 'direct');
found on http://soderlind.no/running-wordpress-locally-on-mac-os-x-lion/#crayon-533a956214a8e343167867
Cheers Can

I fixed it by:
cd /var/www
sudo chown -R www-data:www-data wordpress
Updated on 03-05-2019
cd /var/www
sudo chown -R www-data:www-data [YOUR_WORDPRESS_PROJECT_DIR]

Actually, problem is that WordPress create a temp file to check the file permissions
and it compare that temp file's owner with its a core file's owner (refer fileowner())
both should match. in most of the case, it does not match on localhost hence we extracted wp files in different user access and PHP has its own user group.
So there are 2 ways to solve this problem.
Way 1:
cd wordpress
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
and following
define( 'FS_METHOD', 'direct' );
in wp-config.php
This does not check any fileowners just uses the direct file system
way 2
set
sudo chown -R www-data:www-data wordpress
This sets the both WordPress into www-data use so actually the temp file(which created by WordPress) also comes inside this user, So both fileowners is same so problem solves
More info refer : https://developer.wordpress.org/reference/functions/get_filesystem_method/

Add this in your config.php file,
define('FS_METHOD','direct');

In my experience, WordPress can be a bit fussy about permissions and ownership when it comes to self-update without FTP, so using FTP to localhost is a perfectly valid tactic, I'd say. But as others have said, just ensuring that everything from your WordPress root directory on downwards is writable by the PHP process, and owned by the same user, may well be enough to avoid the need for FTP.
If you do want to use FTP, are you sure you've enabled the FTP server? If so, you should just use a user who has permission to get to the directory via FTP (you can test with the command-line ftp tool.) As my sites are set up in my personal Sites directory, I just use my normal username and password (e.g. for /Users/matt/Sites/whatever I log in as matt.)
Other things to check: What happens if you try ftp localhost on the command line? Can you log in there?

Edit the wp-config.php file and add the piece of code mentioned below:
define('FS_METHOD','direct');

Related

WordPress Plugin update asking for FTP

I moved a WordPress site to our VPS. In admin I am asked to update plugins, if I do that I am prompted for FTP info. As we don't run FTP on the server this is not possible.
I then changed the the permissions of all of the files to apache:apache using:
chown -R apache:apache *
This fixed the issue and WordPress can now update the files, however, now I cannot edit the files using filezilla. I also tried changing ownership to:
chown -R myuser:apache *
So that I can edit the files but give apache group access. Now I can edit the files with filezilla but no longer update items in WordPress.
So, what is the correct way to go about this giving me write access on file level but still giving WordPress access to update the files?
Seems file permission issue.
cd wordpress
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
and following
define( 'FS_METHOD', 'direct' );
in wp-config.php
or
sudo chown -R www-data:www-data wordpress
From WHMPanel, Software, Multi PHP Manager, enable Enable PHP-FPM to fix file permissions issues.
This prevents the popup appearing asking for FTP credentials.

Uploading files with PHP on a linux machine

I'm trying to make some sort of cloud application on a headless raspbian machine.
The testing happens on a wamp-server running on windows8.1. PHP version is 5.6
The code works fine on my testing windows, but I run into issues when running the same code on my linux server. I've narrowed down the issue to the fact that (the linux user behind) my PHP code doesn't have write permissions on the folder where it should store files.
I can think of two ways to solve the issue: either give that php-user permissions, or change the user behind the php code. The last one would be quite interesting if it was possible to change per-script.
So, for my concrete question:
1) Where can I find what user is being used by my PHP code?
2) Can I change what user my PHP code uses, preferably on a per-project basis?
EDIT:
My script was running as root, as is shown by echo get_current_user();. I changed ownership of all files to root:webhosting, which was previously ftpuser:ftpgroup. However, when setting permissions to 770 I get access denied
EDIT2:
When using var_dump(posix_geteuid()); instead of get_current_user();, i get UID 33, which matches user www-data.
SOLUTION:
By looking at the EUID with var_dump(posix_geteuid(); I was able to validate the actual user, which does NOT match the get_current_user();. Changing the directroy and all files in it with sudo chown -R www-data:www-data <root of site> I managed to set the correct permissions.
I am not sure what the specifics are but normally when I have issues like that I change the ownership to www-data:www-data and if necessary for upload folders I change the folder permissions to 0755 and inside files permissions to 0644.
EDIT
I changed the permissions setting for security purposes.
You're PHP/Apache user is probably www-data. You probably want to run something like this.
sudo find path/to/project/ -exec chown www-data:root {} \;
File permissions may also be a problem. If so, run something like this.
sudo find path/to/project/ -type d -exec chmod 775 {} \;
sudo find path/to/project/ -type f -exec chmod 664 {} \;

can't upload file to wordpress

I move my wordpress website to my vps with Cpanel, after move every thing is working well, but my media option can't upload file to my library, I try to set permission for uploads folder and subfolders to 755,775 even 777 but media uploader get me this error :
The uploaded file could not be moved to wp-content/uploads/2016/10.
I try to solve my problem with set group and owner with terminal linux to my user,
> sudo chown -R username:group directory
> sudo chgrp -R username:group directory
but my problem not solved.
Edited :
I try to install "SuPHP" and my problem solved...
for more information see :
https://documentation.cpanel.net/display/EA/Apache+Module%3A+SuPHP
thanks smoqadam
I try to this :
chown -R nobody /home/<username>/public_html/wp-content/uploads/
and everything is OK...
First, I would strongly recommend not setting your permissions to 777. This is a serious security concern. The user wp-user does not exist by default on Ubuntu and is likely left over from the host you exported your site from. All your web files should be owned by www-data. Assuming your web root remains /var/www/html (the default on the WP one-click image) you can fix the ownership with:
chown -Rf www-data:www-data /var/www/html
If that doesn't work you can update the perminssions of the upload folder using the following command
chmod -R 755 /var/www/html/wp-content/uploads
Try this:
sudo chown -R www-data:www-data <path_to_your_web_root>
(If that still doesn't work, make sure the uploads folder etc. are not at 777 permission - you can use this for that purpose:
sudo chmod -R 755 <path_to_your_web_root> )
)

phpMyAdmin "Cannot load or save configuration"

I have been trying to setup phpMyAdmin on a macbook pro running yosemite 10.10.2. I have created a config folder in phpmyadmin and have given it the permissions required:
chmod o+wr ~/Sites/phpmyadmin/config
However, when I then go onto "localhost/phpmyadmin/setup" I get an error:
Cannot load or save configuration
Please create web server writable folder config in phpMyAdmin top level
directory as described in documentation. Otherwise you will be only able to
download or display it.
(I have tried attaching an image, but can't due to my reputation points)
I have tried resetting the permissions, tried deleting and recreating the folder. Tried redownloading the phpmyadmin zip but nothing seems to work.
Could anyone kindly advise me what I am doing wrong and how I am best placed to solve this issue?
I have had similar issue on my Ubuntu 16.04. I made a research and in the end I found a resolution of the issue. Maybe my case solution will help somebody else.
Background: For security reasons I have non privileged user and group apache:apache (sudo groupadd apache | useradd -g apache apache). They are preset by directives (User apache; Group apache) in /etc/apache2/apache2.conf. This user apache:apache owns Apache2 main directory (sudo chown -R apache:apache /etc/apache2) and some other files, for example: sudo chown -R apache:apache/etc/phpmyadmin/htpasswd.setup
In this manual: http://docs.phpmyadmin.net/en/latest/setup.html - I found that...
Debian and Ubuntu have changed way how setup is enabled and disabled,
in a way that single command has to be executed for either of these.
To allow editing configuration invoke:
/usr/sbin/pma-configure
To block editing configuration invoke:
/usr/sbin/pma-secure
Note! In the content of the two files listed above we talk about /var/lib/phpmyadmin/config.inc.php instead of /etc/phpmyadmin/config/config.inc.php. It was the key.
In my case I was modified the content of these scripts (see below) and now I can use localhost/phpmyadmin/setup properly.
/usr/sbin/pma-configure:
#!/bin/sh
echo "Unsecuring phpMyAdmin installation..."
echo "Setup script can now write to the configuration file."
echo
echo "Do not forget to run /usr/sbin/pma-secure after configuring,"
echo "otherwise your installation might be at risk of attack."
sudo sudo chown -R apache:apache /var/lib/phpmyadmin/config.inc.php
chmod 0660 /var/lib/phpmyadmin/config.inc.php
/usr/sbin/pma-secure:
#!/bin/sh
echo "Securing phpMyAdmin installation..."
echo "Setup script won't be able to write configuration."
sudo sudo chown -R root:root /var/lib/phpmyadmin/config.inc.php
chmod 0640 /var/lib/phpmyadmin/config.inc.php
I was able to use phpMyAdmin in my ~/Sites directory and remove the warning by giving the config folder writable access as such:
chmod 756 ~/Sites/phpmyadmin/config
Does it work if you try setting up PHPMyAdmin in system root versus user root? On OSX that server web root should be under /Library/WebServer/Documents?
I used this guide when I set mine up, and it works fine, although I did not use Sites as my root.
http://www.dingendoen.com/osx-installs-configuration-examples/install-apache-mysql-php-on-osx-yosemite/
For local development, changing permissions worked for an OSX Sierra install:
sudo chown -R _www:_www ~/Sites/phpmyadmin

Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server?

Hi anyone can help me for this issue , I have developed a site and it is hosted on my development server but now my client wants to move it to his own production server, and my client doesn't have access to his cpanel for this server. I only have the ftp access, so I have added his database in my own development server, while in development I used my amazon s3 for storing the images , when I push to production I loss the amazon plugin . I can't able to install the plugin , so I moved to upload once again to those images through WordPress, now I face this error while uploading an image : Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server? , and change the ftp file permission access to 755 and changed the uploads file permission to 777 , Still I am not able to upload the images, can some one help me for this issue.
This is a problem of the Apache permissions. I had this problem and i broke my mind for many days to understand what was happening.
The correct way (USE IT):
(the solution that i used, and worked)
You need to give Rewrite permissions to the Apache.
For Ubuntu:
Run via ssh: chown -R www-data:www-data /var/www/the/wordpress/directory
For Centos:
Run via ssh: chown -R apache.apache /var/www/the/wordpress/directory
The Wrong Way (I don't recommend it, but works...)
You can change the permissions to 777 in all the paths that Wordpress need to change. wp-content/plugins recursively on folders to solve install/update problems, and wp-content/uploads recursively on folders to solve upload media problems.
Never use it because you are giving permissions to anyone change your files. A open way for the crackers that don't like you.
run these command to provide proper file permissions
Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
Set group ownership inheritance
sudo chmod g+s /var/www/html/;
Set the permissions of the files/directories
sudo find /var/www/html/ -type d -exec chmod 755 {} ;
sudo find /var/www/html/ -type f -exec chmod 644 {} ;
Give write permissions to the group (for editing files via FTP)
sudo chmod -R g+w /var/www/html/;

Categories