{"id":543,"date":"2016-11-12T18:31:41","date_gmt":"2016-11-12T10:31:41","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=543"},"modified":"2018-09-05T00:13:07","modified_gmt":"2018-09-04T16:13:07","slug":"how-to-manually-update-wordpress-installation-on-a-lemp-stack-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-to-manually-update-wordpress-installation-on-a-lemp-stack-on-ubuntu\/","title":{"rendered":"How to manually update WordPress installation on a LEMP stack on Ubuntu"},"content":{"rendered":"<p><a href=\"https:\/\/wordpress.org\/\" title=\"WordPress.org homepage\" target=\"_blank\">WordPress<\/a> constantly evolves to give website owners more features and security improvements to make their website great. After getting over with months of procrastination on updating my WordPress installation, I had finally get my act together to proceed with updating my WordPress installation.<\/p>\n<p>As I do not like to give my PHP-FPM and Nginx write access to the directory that contains my WordPress installation, I had decided to update my WordPress installation manually.<\/p>\n<p>I document the steps that I had went through to manually update my <a href=\"https:\/\/www.techcoil.com\/blog\/setting-up-a-lemp-web-server-on-raspberry-pi-3-with-an-ubuntu-server-15-10-3-image-to-host-a-wordpress-website\/\" target=\"_blank\" title=\"Setting up a LEMP web server on Raspberry Pi 3 with an Ubuntu Server 15.10.3 image to host a WordPress website\">WordPress installation on my LEMP stack on Ubuntu<\/a> in this post for future references.<\/p>\n<h2>Backing up our WordPress database<\/h2>\n<p>Unless we have a cron job that helps us backup our WordPress database, it is advisable to backup our WordPress database before proceeding with the manual update of our WordPress installation. To backup our WordPress database, we can run the following command in our shell program:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmysqldump -u db_username -p database_name &gt; \/location\/to\/backup\/database_name_YYYYMMDD.sql\r\n<\/pre>\n<p>This will create a sql script that we can use if we need to revert the changes that WordPress does to our database during the update process.<\/p>\n<h2>Deactivating all our plugins<\/h2>\n<p>After making sure that we have a backup of our WordPress database to guard against any catastrophe, we can then proceed to deactivate our plugins. To deactivate all our plugins:<\/p>\n<ul>\n<li>access our WordPress admin Dashboard with a web browser,<\/li>\n<li>go to Plugins -&gt; Installed Plugins,<\/li>\n<li>check the checkbox beside Plugin,<\/li>\n<li>choose 'Deactivate' from the 'Bulk Actions' combobox, and<\/li>\n<li>click 'Apply' next to the 'Bulk Actions' combobox<\/li>\n<\/ul>\n<h2>Getting the latest copy of WordPress<\/h2>\n<p>After deactivating all our plugins, the next step is to download the latest copy of WordPress. To minimize bandwidth costs and download time, it is better to download the latest copy of WordPress from within our Ubuntu server. To download the latest copy of WordPress, we can run the following commands in our shell:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd ~\/an\/empty\/folder\r\nwget http:\/\/wordpress.org\/latest.tar.gz\r\ntar xzvf latest.tar.gz\r\n<\/pre>\n<p>With the above commands, we first get the shell into an empty folder inside of the home directory. We then download a <code>.tar.gz<\/code> file that contains the latest WordPress codes. After the download had completed, we then extract the <code>wordpress<\/code> folder from the <code>.tar.gz<\/code> file. With that, we will have the latest WordPress codes at <code>~\/an\/empty\/folder\/wordpress<\/code>.<\/p>\n<h2>Porting over the customized codebase from our old WordPress to the latest one<\/h2>\n<p>Once we have the latest copy of WordPress in <code>~\/an\/empty\/folder\/wordpress<\/code>, we can copy the customized codes into the new WordPress folder. Assuming that our existing WordPress folder is located at \/mywebsite, we can run the following commands in our shell to port the customized codes from the existing WordPress folder to the new WordPress folder:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo cp \/mywebsite\/wordpress\/wp-config.php ~\/an\/empty\/folder\/wordpress\/wp-config.php\r\nsudo cp -R \/mywebsite\/wordpress\/wp-content\/ ~\/an\/empty\/folder\/wordpress\r\n<\/pre>\n<p>With the above commands, we move our <code>wp-config.php<\/code> and everything in our <code>wp-content<\/code> folder from the existing WordPress installation folder to the new WordPress folder.<\/p>\n<h2>Making the shift from old to new<\/h2>\n<p>Once we had moved our customized codes to the new WordPress folder, it is time to make the shift from old to new. To do so, we run the following command in our shell:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mv \/mywebsite\/wordpress \/mywebsite\/wordpress-old\r\nsudo mv ~\/an\/empty\/folder\/wordpress \/mywebsite\/wordpress\r\n<\/pre>\n<p>With the above commands, we first rename the existing WordPress folder to <code>wordpress-old<\/code>. We then move the new wordpress folder to the same location where the old WordPress had resided at. <\/p>\n<h2>Restarting PHP-FPM<\/h2>\n<p>Once we had made the shift from old to new, we can restart our PHP-FPM.<\/p>\n<p>To restart the PHP-FPM process for PHP 5 in Ubuntu 14 and earlier, we can run the following command in our shell:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo service php5-fpm restart\r\n<\/pre>\n<p>To restart the PHP-FPM process for PHP 5 in Ubuntu 15 and later, we can run the following command in our shell:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart php5-fpm.service\r\n<\/pre>\n<h2>Triggering the new WordPress codes to update the database<\/h2>\n<p>After our PHP-FPM process restarted, the new WordPress codes will be used to process subsequent HTTP requests to our WordPress website. The last step to the manual update of our WordPress website is to get the new WordPress codes to update the database. To trigger the new WordPress codes to update the database, we access our WordPress admin page with our web browser and click on the button that appears.<\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-8L\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-8L&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-8L&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F543&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/wordpress.org\/\" title=\"WordPress.org homepage\" target=\"_blank\">WordPress<\/a> constantly evolves to give website owners more features and security improvements to make their website great. After getting over with months of procrastination on updating my WordPress installation, I had finally get my act together to proceed with updating my WordPress installation.<\/p>\n","protected":false},"author":1,"featured_media":1217,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[242,243,195,224,5],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/WordPress-logo-on-black-background.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-8L","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/543"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1217"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}