darknite
By:
darknite

Wordpress FTP password and recommenced ebooks for linux, centos and server management

April 23, 2017 279 views
Nginx WordPress CentOS

What is my wordpress ftp password...

I saw a potential fix but I think its for Apache

ryanpq MOD April 10, 2017
Accepted Answer
WordPress will ask for these credentials if it detects that it does not have permission to write the needed files itself. This can be avoided completely by resetting these permissions so the files are owned by the user account used by your web server.

If you are on Ubuntu or Debian you can run the following command on your droplet to set these permissions for the default web root of /var/www/html

chown -Rf www-data:www-data /var/www/html

and any recommenced Ebooks to learn linux, centos and server management for total beginners..

3 Answers
jtittle1 April 23, 2017
Accepted Answer

@darknite

With NGINX + PHP-FPM, the same solution works as long as www-data is the user configured to run your PHP-FPM instance.

The pool files which set the user and group are located in:

/etc/php/7.0/fpm/pool.d

If you're running a version other than 7.0 (5.6 or 7.1), simply change 7.0 to that version in the above.

Inside the ./pool.d directory you'll see a file called www.conf which will contain the user and group that the specific pool is configured to run as. If you've not modified this file, it's www-data.

So what you need to do in order to setup your installation so that you don't need to setup FTP/SFTP is chown your files and directories to www-data so that when a request is processed by PHP, it has the permissions needed to read/write.

So if your files are located in /var/www/html, then running the command that Ryan provided is what you need to do.

If they are located elsewhere, then you need to change the path to that of where your files reside.

...

As a general note, the above path is for Ubuntu. It may differ on CentOS. The best way to find out would be to create a temporary file called info.php and inside it, add:

<?php phpinfo();

Save and then access it via the web.

Find Configuration File (php.ini) Path and that will be where you need to look. Once you find the path, delete that file as you no longer need it and don't really want everything exposed publicly.

...

As far as learning how to manage a server, the guides here on DigitalOcean and Google are the best places to start. Check the dates and make sure they are recent.

Setup a small 512MB-1GB Droplet for testing as you learn -- use it exclusively for learning so that you don't potentially damage to your current live environment.

Most of the basics of Linux can be learned from the man pages. So, for example, if you wanted to learn all about the cp command (i.e. copy), you could run man cp or even cp --help. The same works for pretty much any command:

man cp
man mv
man rm
...
cp --help
mv --help
rm --help

Once you get familiar with the basics, you can move up from there.

When I've worked with individuals and guided/tutored them on basics and more advanced items (such as compiling NGINX from source, setting up Load Balancers and Proxies, etc), the basics are always what I recommend starting with.

Without the basics, it's hard to do bash scripting (since you rely on the basics to write bash scripts) or even know what to do when it comes to doing more advanced setups.

...

Beyond reading the man pages, and the guides here at DigitalOcean or available via Google, ask questions if you don't know how to do something and want to learn.

Thx ill test it when I wake up. off to sleep now.
Pls rec me some books to read to get better at it.

  • @darknite

    There are plenty of books on Amazon, though none that I'd honestly recommend.

    I used to have half a book shelf full of various Linux books. They sat and collected dust because it's far easier to Google something than it is to find the book I saw something interesting in, then the page in a chapter or sub-chapter, and then read over it.

    Most books really only scratch the surface because they are limited. For example, one might do a whole chapter on brace expansion because it can be complex (or you can make it complex).

    As an example, take mkdir which creates a directory. If a parent directory exists and we want to create a child of the parent, we can run:

    mkdir /home/darknite
    

    If the parent directory doesn't exist, we can pass -p as an argument which creates the parents of the children so that we don't have to run the command multiple times.

    i.e.

    We know /home exists and now (with the above), so would /home/darknite, but if we try:

    mkdir /home/darknite/htdocs/public
    

    That'll fail because ./htdocs doesn't exist. That's where -p comes in handy.

    mkdir -p /home/darknite/htdocs/public
    

    Now all those directories exist. Now, I mentioned brace expansion, that's how we can create a huge number of directories using one mkdir command.

    Let's say we have 4 user directories to create and each of them needs htdocs/public and an htdocs/private directory, we can run:

    mkdir -p /home/{user1,user2,user3,user4}/htdocs/{public,private}
    

    That one command will create:

    /home/user1/htdocs/public
    /home/user1/htdocs/private
    /home/user2/htdocs/public
    /home/user2/htdocs/private
    /home/user3/htdocs/public
    /home/user3/htdocs/private
    /home/user4/htdocs/public
    /home/user4/htdocs/private
    

    Now, that's not all brace expansion is good for, of course, but that gives you an idea of how a book could be limited. Writing different examples like this could take up 10-20 pages of a 200-500 page book. If each example did, there'd only be 10 or so chapters :-).

    ...

    What I would honestly recommend is simply using Google to start.

    For example, maybe you want to know more about Bash Scripting, we'll Google lead me to a really good resource a long time ago.

    http://wiki.bash-hackers.org/

    When you search for bash arrays, it's one of the top results.

    Now if you wanted to learn more about another way to do something, ask Google and soak up all that you can. Learning the basics is relatively easy, remembering can be a bit harder but gets easier over time and when you start getting hands-on.

thanks the answer worked but needed to tweak it to my needs

the folder was : /etc/php-fpm.d
and my nginx folder was /usr/share/nginx/html

"chown -Rf nginx:nginx /usr/share/nginx/html" worked for me.
Have another answer? Share your knowledge.