{"id":8214,"date":"2022-03-07T13:21:51","date_gmt":"2022-03-07T21:21:51","guid":{"rendered":"https:\/\/codedcommerce.com\/?p=8214"},"modified":"2024-06-19T14:31:32","modified_gmt":"2024-06-19T21:31:32","slug":"tips-on-using-localwp-for-wordpress-sandboxing","status":"publish","type":"post","link":"https:\/\/codedcommerce.com\/tips-on-using-localwp-for-wordpress-sandboxing\/","title":{"rendered":"Tips on using LocalWP sandboxing"},"content":{"rendered":"\n<div class=\"wp-block-group has-white-color has-secondary-background-color has-text-color has-background has-link-color wp-elements-1c9be83f21b82acc5178943f7886c009 has-global-padding is-layout-constrained wp-container-core-group-is-layout-0910e091 wp-block-group-is-layout-constrained\" style=\"border-radius:4px;padding-top:var(--wp--preset--spacing--40);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--40)\">\n<p class=\"wp-block-paragraph\"><strong>June 2024 update:<\/strong> These days I recommend the lightening fast <a href=\"https:\/\/spinupwp.com\/?referral=3Q5ewR1rP4\" data-type=\"link\" data-id=\"https:\/\/spinupwp.com\/?referral=3Q5ewR1rP4\" target=\"_blank\" rel=\"noreferrer noopener\">SpinupWP control panel<\/a> connected to a Dedicated CPU Premium Intel server at <a href=\"https:\/\/m.do.co\/c\/71abd3877cc0\" data-type=\"link\" data-id=\"https:\/\/m.do.co\/c\/71abd3877cc0\" target=\"_blank\" rel=\"noreferrer noopener\">Digital Ocean<\/a>. This is faster than any local environment I&#8217;ve ever used. Remember to follow good security practices and password protect any dev environment.<\/p>\n<\/div>\n\n\n\n<p class=\"has-drop-cap wp-block-paragraph\"><a rel=\"noreferrer noopener\" href=\"https:\/\/localwp.com\/\" data-type=\"URL\" data-id=\"https:\/\/localwp.com\/\" target=\"_blank\">LocalWP<\/a>, known as <em>Local<\/em> and formerly <em>Local by Flywheel<\/em>, is a free, user-friendly and popular sandbox hosting environment for developing WordPress sites.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Local sandboxes run directly on your workstations and are generally isolated to each machine as opposed to being available on the Internet. They also bundle useful features for site installation, migration, database administration, command line tools, and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Flywheel was acquired by <a href=\"https:\/\/wpengine.com\/more\/partnerspecialoffer\/?w_agcid=aEA1ne5a\" data-type=\"URL\" data-id=\"https:\/\/wpengine.com\/more\/partnerspecialoffer\/?w_agcid=aEA1ne5a\" target=\"_blank\" rel=\"noreferrer noopener\">WP Engine<\/a> in June 2019 and Local began offering synchronization features with WP Engine sites in February 2020. WP Engine also made <a rel=\"noreferrer noopener\" href=\"https:\/\/localwp.com\/pro-for-everyone\/\" data-type=\"URL\" data-id=\"https:\/\/localwp.com\/pro-for-everyone\/\" target=\"_blank\">Local Pro features available to everybody<\/a> for free starting in June 2021.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After working with many local hosting environments including Docker, VVV, XAMPP, MAMP, Homebrew; I must say this one is the most useful for WordPress sites. I&#8217;ll provide some pro tips based on how I like to use it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>WP-CLI (WordPress command line)<\/strong> tools are available by right-clicking on a site name in the Local App and choosing <em>Open Site Shell<\/em>. I often run <em>wp search-replace OLDURL NEWURL<\/em> to change domains and protocols after importing databases.<\/li>\n\n\n\n<li><strong>A SQL backup file is created<\/strong> whenever a site is stopped. This is a handy file to copy as a backup, especially before deleting a site from your list. It&#8217;s stored in the file <em>Local Sites > [site] > app > sql > local.sql<\/em>\n<ul class=\"wp-block-list\">\n<li>When restoring a SQL file to LocalWP you may first need to run <code>SET GLOBAL SQL_MODE ='ALLOW_INVALID_DATES';<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Sometimes you need <a href=\"https:\/\/www.phpmyadmin.net\/\" target=\"_blank\" rel=\"noreferrer noopener\">PhpMyAdmin<\/a><\/strong> instead of the built-in <a href=\"https:\/\/www.adminer.org\/\" data-type=\"URL\" data-id=\"https:\/\/www.adminer.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Adminer<\/a> database tool. Download PhpMyAdmin, install it into its own folder within your site&#8217;s <em>app\/public\/<\/em> folder, access it from the browser and use credentials root \/ root to login. Easy!<\/li>\n\n\n\n<li><strong>You can change your configurations<\/strong> inside your Local Sites folder by clicking on the site&#8217;s folder and the <em>conf<\/em> folder within. Restart the site after making changes. Use your computer&#8217;s Activity Monitor App to keep an eye on CPU and RAM utilization.<ul><li><strong>Routing images from production<\/strong> can be very useful when you don&#8217;t want to cache gigabytes on your workstation. This setup varies between Apache and Nginx.<ul><li>Nginx rewrite for your <em>site.conf<\/em> file: <code>location @production { resolver 8.8.8.8; proxy_pass https:\/\/mysite.com\/$uri; }<\/code> then append <code>try_files $uri $uri\/ @production;<\/code> to the bottom of your image and font file extension <code>location {}<\/code> definitions.<\/li><li>If Cloudflare in production is blocking rewrites you can setup a 301 redirect instead: <code>rewrite ^\/wp-content\/uploads\/(.*)\/(.*)\/(.*)$ https:\/\/mysite.com\/$1\/$2\/$3 permanent;<\/code> into your <code>server {}<\/code> declaration.<\/li><\/ul><\/li><\/ul>\n<ul class=\"wp-block-list\">\n<li><strong>MySQL is tuned for very low memory.<\/strong> For larger databases such as sites with lots of order history you should edit the <em>my.cnf<\/em> file and change <em>innodb_buffer_pool_size<\/em> from 32M (default 128M) up to half of your total RAM.<\/li>\n\n\n\n<li><strong>PHP-FPM is tuned for low activity<\/strong> with two workers. For more active sandboxes such as those running a lot of AJAX requests you can change your <em>www.conf<\/em> file to use the <em>ondemand<\/em> process manager and bump <em>max_children<\/em> to an appropriate number. For example with 8GB of RAM you can set it up to 8GB \/ 2 = 4GB \/ 75M per request memory footprint = 50 (rounded down) maximum child processes.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>June 2024 update: These days I recommend the lightening fast SpinupWP control panel connected to a Dedicated CPU Premium Intel server at Digital Ocean. This is faster than any local environment I&#8217;ve ever used. Remember to follow good security practices and password protect any dev environment. LocalWP, known as Local and formerly Local by Flywheel, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8215,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52047,635718626],"tags":[],"class_list":["post-8214","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","category-wordpress-guides"],"jetpack_featured_media_url":"https:\/\/codedcommerce.com\/wp-content\/uploads\/2022\/03\/LocalWP.png","_links":{"self":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/posts\/8214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/comments?post=8214"}],"version-history":[{"count":0,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/posts\/8214\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/media\/8215"}],"wp:attachment":[{"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/media?parent=8214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/categories?post=8214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codedcommerce.com\/wp-json\/wp\/v2\/tags?post=8214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}