{"id":745,"date":"2015-03-14T11:22:45","date_gmt":"2015-03-14T15:22:45","guid":{"rendered":"http:\/\/tech.creed3.com\/?p=745"},"modified":"2015-03-14T11:22:45","modified_gmt":"2015-03-14T15:22:45","slug":"updating-wp-on-a-local-server","status":"publish","type":"post","link":"https:\/\/tech.creed3.com\/?p=745","title":{"rendered":"Updating WP on a Local Server"},"content":{"rendered":"<p><img decoding=\"async\" style=\"margin: 0 4px 4px 0;\" alt=\"\" src=\"images\/stories\/wordpress-logo-simplified-rgb.png\" width=\"100\" align=\"left\" border=\"0\" \/>I have a development Mac server on my local network that I use for developing new web sites or themes or you name it. &nbsp;My WP sites also run there as well. &nbsp;The problem has been getting WP to update on this server without providing my FTP credentials every time. &nbsp;I finally found a solution.<!--more--><\/p>\n<p>I spent a lot of time searching online for this. &nbsp;The problem seems to be that of Apache not having permission to write to the WP folders or files. &nbsp;So I searched to double checked how these permissions should be set, verified that _www is the &#8216;user&#8217; running Apache, reset everything to be owned by the _www group with write permissions, and low and behold it didn&#8217;t work. &nbsp;Okay, that was a surprise.<\/p>\n<p>So I decided to verify again that _www really was the &#8216;user&#8217; running Apache and inserted this at the top of the index.php:<\/p>\n<pre><code>echo(exec(\"whoami\"));<\/code><\/pre>\n<p>Reload the page and yes, &#8216;_www&#8217; appeared at the top. &nbsp;Don&#8217;t forget to remove this if you utilize it.<\/p>\n<p>File and folder permissions are correct (double and triple checked thinking I may have missed something). &nbsp;More searching. &nbsp;Which btw, this seems to be a pretty common frustration for WP admins.<\/p>\n<p>There are many sites promoting the idea of embedding your FTP credentials in the wp_config.php file. &nbsp;What this does is provided the requested info and save you from entering it each time you need to update WP or a plugin. &nbsp;I can see the merit of this yet this is only an issue on my local server. &nbsp;I&#8217;d prefer, no matter how safe it may be, to not provide those credentials on the live server, which is why I won&#8217;t post that method here. &nbsp;I believer in the best security is that where the info cannot be reached in any way. &nbsp;So to accomplish this you&#8217;d have to remember to remove those credentials every time you upload that file to the liver server, or have 2 versions of that file. &nbsp;Neither solution appeals so I kept looking for another.<\/p>\n<p>Something else I&#8217;ve seen showing up in searches is another edit to the wp_config.php file. &nbsp;This time it&#8217;s to call a built-in WP function to bypass the security for updating the site. &nbsp;I&#8217;m not really fond of a security bypass either. &nbsp;However I decided since this is a WP function it would have to be a little more secure than embedding your FTP credentials, since this would only affect your WP installation and not be an open door to the server as FTP would provide.<\/p>\n<p>The function call to add to your wp_config.php file is this:<\/p>\n<pre><code>define('FS_METHOD', 'direct');<\/code><\/pre>\n<p><a href=\"http:\/\/codex.wordpress.org\/Editing_wp-config.php#WordPress_Upgrade_Constants\" target=\"_blank\">Here&#8217;s what WP has to say about it.<\/a><\/p>\n<p>In pondering this I remembered something I used to do at work to restrict certain sensitive tasks to a development server and not for use on a live server. &nbsp;That is to perform a simple check to see which server is running the file in question. &nbsp;If it&#8217;s the dev server then perform a certain task. &nbsp;Otherwise it&#8217;s ignored. &nbsp;That&#8217;s perfect. &nbsp;Not only am I not embedding my FTP credentials, but also the WP function that relaxes security a bit is only called on my dev server. &nbsp;Here&#8217;s the code:<\/p>\n<pre><code>if ($_SERVER['SERVER_ADDR'] == 'XXX.XXX.XXX.XXX'){define('FS_METHOD', 'direct');}<\/code><\/pre>\n<p>Of course you need to change XXX.XXX.XXX.XXX to what ever your server local IP address is.<\/p>\n<p>This did the trick for me. &nbsp;Hopefully it will help someone else down the road as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a development Mac server on my local network that I use for developing new web sites or themes or you name it. &nbsp;My WP sites also run there as well. &nbsp;The problem has been getting WP to update on this server without providing my FTP credentials every time. &nbsp;I finally found a solution.<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,30,41],"tags":[31],"class_list":["post-745","post","type-post","status-publish","format-standard","hentry","category-technology","category-web-development","category-wordpress","tag-wordpress"],"views":1948,"_links":{"self":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts\/745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=745"}],"version-history":[{"count":0,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts\/745\/revisions"}],"wp:attachment":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}