<\/span><\/h2>\nIf you get an error when uploading an image to your WordPress based site, it may be due to PHP configuration settings on your server, like insufficient memory limit or so.<\/p>\n
Locate the php configuration file using the following command:<\/p>\n
#php -i | grep php.ini\r\nConfiguration File (php.ini) Path => \/etc\r\nLoaded Configuration File => \/etc\/php.ini<\/pre>\nAccording to the output, the PHP configuration file is located in the ‘\/etc’ directory, so edit the ‘\/etc\/php.ini’ file, find the lines below and modify them with these values:<\/p>\n
vi \/etc\/php.ini<\/pre>\nupload_max_filesize = 64M\r\npost_max_size = 32M\r\nmax_execution_time = 300\r\nmax_input_time 300\r\nmemory_limit = 128M<\/pre>\nOf course if you are unfamiliar with the vi text editor, use your favorite one.<\/p>\n
Do not forget to restart your web server for the changes to take effect.<\/p>\n
If the web server installed on your server is Apache, you may use .htaccess. First, locate the .htaccess file. It should be in the document root directory of the WordPress installation. If there is no .htaccess file, create one, then add the following content:<\/p>\n
vi \/www\/html\/path_to_wordpress\/.htaccess<\/pre>\nphp_value upload_max_filesize 64M\r\nphp_value post_max_size 32M\r\nphp_value max_execution_time 180\r\nphp_value max_input_time 180\r\n\r\n# BEGIN WordPress\r\n<IfModule mod_rewrite.c>\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^index\\.php$ - [L]\r\nRewriteCond %{REQUEST_FILENAME} !-f\r\nRewriteCond %{REQUEST_FILENAME} !-d\r\nRewriteRule . \/index.php [L]\r\n<\/IfModule>\r\n# END WordPress<\/pre>\nIf you are using nginx, configure the nginx server block about your WordPress instance. It should look something like the example below:<\/p>\n
server {\r\n\r\nlisten 80;\r\nclient_max_body_size 128m;\r\nclient_body_timeout 300;\r\n\r\nserver_name your-domain.com www.your-domain.com;\r\n\r\nroot \/var\/www\/html\/wordpress;\r\nindex index.php;\r\n\r\nlocation = \/favicon.ico {\r\nlog_not_found off;\r\naccess_log off;\r\n}\r\n\r\nlocation = \/robots.txt {\r\nallow all;\r\nlog_not_found off;\r\naccess_log off;\r\n}\r\n\r\nlocation \/ {\r\ntry_files $uri $uri\/ \/index.php?$args;\r\n}\r\n\r\nlocation ~ \\.php$ {\r\ninclude fastcgi_params;\r\nfastcgi_pass 127.0.0.1:9000;\r\nfastcgi_index index.php;\r\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n}\r\n\r\nlocation ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {\r\nexpires max;\r\nlog_not_found off;\r\n}\r\n}<\/pre>\nDepending on the PHP configuration, you may need to replace ‘fastcgi_pass 127.0.0.1:9000;’ with ‘fastcgi_pass unix:\/var\/run\/php7-fpm.sock;’ or so.<\/p>\n
Restart nginx service for the changes to take effect.<\/p>\n