{"id":192,"date":"2011-09-24T13:46:23","date_gmt":"2011-09-24T05:46:23","guid":{"rendered":"http:\/\/thereforeiam.wordpress.com\/?p=192"},"modified":"2011-09-24T13:46:23","modified_gmt":"2011-09-24T05:46:23","slug":"wordpress-upload-problem","status":"publish","type":"post","link":"https:\/\/www.brainfart.sg\/index.php\/2011\/09\/wordpress-upload-problem\/","title":{"rendered":"WordPress Upload Problem"},"content":{"rendered":"<p>I&#8217;ve finished setting up the LNMP stack on my VPS, and got WordPress running on it.<\/p>\n<p>I will be sharing the steps I&#8217;ve done to setup the LNMP stack on a later date, but first, I&#8217;d like share an issue I&#8217;ve encountered after getting WordPress up and running.<\/p>\n<p>After running the install.php script and doing up the settings of my WordPress site, I tried to upload a free theme pack from <a title=\"WooThemes\" href=\"http:\/\/www.woothemes.com\" target=\"_blank\">WooThemes<\/a>. (<a title=\"Typebased Theme\" href=\"http:\/\/demo.woothemes.com\/typebased\/\" target=\"_blank\">Typebased<\/a>, if you are wondering which one)<\/p>\n<p>The first problem I hit was the server giving me a &#8220;Connection Reset&#8221; everytime I tried to upload the theme. In the Nginx error log, this was recorded:<\/p>\n<pre class=\"brush: plain; light: false; title: ; wrap-lines: true; notranslate\" title=\"\">\n2011\/09\/24 07:34:58 [error] 30097#0: *70 client intended to send too large body: 2617076 bytes, client: 202.156.8.11, server: www.brainfart.sg, request: &amp;quot;POST \/wp-admin\/update.php?action=upload-theme HTTP\/1.1&amp;quot;, host: &amp;quot;www.brainfart.sg&amp;quot;, referrer: &amp;quot;http:\/\/www.brainfart.sg\/wp-admin\/theme-install.php?tab=upload&amp;quot;\n<\/pre>\n<p>The &#8220;client intended to send too large body&#8221; tells us that Nginx was rejecting the theme zip file as it was too big (it&#8217;s 2.49MB in size). A check on the Nginx Wiki shows that the default maximum size accepted by Nginx is <a href=\"http:\/\/wiki.nginx.org\/HttpCoreModule#client_max_body_size\" target=\"_blank\">1MB<\/a>, and Nginx resets the connection whenever a browser tries to send or request a file greater than 1MB. So we&#8217;ll have to update the nginx.conf file with the &#8220;client_max_body_size&#8221; directive to get Nginx to send and receive a bigger file. I&#8217;ve changed mine to a value of 3MB and you may adjust yours accordingly. Note that the directive is placed in the &#8220;http&#8221; section.<\/p>\n<pre class=\"brush: plain; light: false; title: ; notranslate\" title=\"\">\n...\nhttp {\n...\nclient_max_body_size 3M;\n...\n}\n<\/pre>\n<p>I tried to upload the theme file again, and this time the file was accepted by Nginx without a problem. However, WordPress threw an error, &#8220;The uploaded file could not be move to &#8230;\/wp-content\/uploads.&#8221; Not a very intuitive error, seems like it is a permission issue with WordPress trying to write to the uploads directory&#8230; The logs weren&#8217;t showing any error and a Google search resulted in quite a few people having the same problem.<\/p>\n<p>Most of the resolution are to do with setting the correct permission for the uploads directory. A check with my uploads directory shows that the permissions are correct \u00a0and I even tried to give full 777 permission to the directory! But error still persist&#8230; It took me quite a while, trying to figure out what&#8217;s wrong and then it suddenly hit me! It could be related to the Nginx size error, but at the PHP layer. A quick Google shows that PHP has a &#8220;upload_max_filesize&#8221; and &#8220;post_max_size&#8221; directive, so I updated my php.ini to include the two directives:<\/p>\n<pre class=\"brush: plain; light: false; title: ; notranslate\" title=\"\">\n...\nupload_max_filesize = 3M\npost_max_size = 3M\n...\n<\/pre>\n<p>Bingo! \u00a0The theme file went through and was installed in WordPress.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve finished setting up the LNMP stack on my VPS, and got WordPress running on it. I will be sharing the steps I&#8217;ve done to setup the LNMP stack on a later date, but first, I&#8217;d like share an issue&hellip; <a href=\"https:\/\/www.brainfart.sg\/index.php\/2011\/09\/wordpress-upload-problem\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"spay_email":""},"categories":[17],"tags":[49,51,54,78,79],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1T66h-36","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts\/192"}],"collection":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":0,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}