{"id":3675,"date":"2020-07-24T15:44:49","date_gmt":"2020-07-24T22:44:49","guid":{"rendered":"http:\/\/www.hi-alex.com\/?p=3675"},"modified":"2020-07-24T15:44:49","modified_gmt":"2020-07-24T22:44:49","slug":"3675","status":"publish","type":"post","link":"http:\/\/www.hi-alex.com\/?p=3675","title":{"rendered":"\u6298\u817eRaspberry Pi\uff1aMigrating WordPress to Raspberry Pi"},"content":{"rendered":"<h3>Preparation<\/h3>\n<h4>Take full backup of existing system<\/h4>\n<h4>Copy files to USB drive (extFat format)<\/h4>\n<p>&nbsp;<\/p>\n<h3>On Raspberry Pi:<\/h3>\n<h4>Update system<\/h4>\n<p><code>sudo apt-get update<\/code><br \/>\n<code>sudo apt-get upgrade<\/code><\/p>\n<h4>Mount USB Drive<\/h4>\n<p><code>sudo apt install exfat-fuse exfat-utils<\/code><\/p>\n<h4>Install Apache<\/h4>\n<p><code>sudo apt install apache2 -y<\/code><\/p>\n<h4>Install MariaDB<\/h4>\n<p><code>sudo apt-get install mariadb-server -y<\/code><\/p>\n<h4>Install PHP<\/h4>\n<p><code>sudo apt-get install php php-mysql -y<\/code><\/p>\n<h4>Install PHPMyAdmin<\/h4>\n<p><code>sudo apt install phpmyadmin<\/code><br \/>\n<code>select \"apache2\" option by pressing SPACE and then ENTER<\/code><br \/>\n<code>select \"Yes\" at the next prompt<\/code><br \/>\n<code>Set a password for PHPMyAdmin<\/code><\/p>\n<h4>Create a new user to create and access data tables within PHPMyadmin<\/h4>\n<p><code>sudo mysql -u root -p<\/code><br \/>\n<code>GRANT ALL PRIVILEGES ON *.* TO '<span style=\"text-decoration: underline;\">username<\/span>'@'localhost' IDENTIFIED BY '<span style=\"text-decoration: underline;\">password_set_in_previous_step<\/span>' WITH GRANT OPTION;<\/code><br \/>\nexit out of MySQL cmd line by typing &#8220;quit&#8221; in the terminal<\/p>\n<h4>Configuring Apache for PHPMyAdmin<\/h4>\n<p><code>sudo nano \/etc\/apache2\/apache2.conf<\/code><br \/>\nAdd the following line to the bottom of the file:<br \/>\n<code>Include \/etc\/phpmyadmin\/apache.conf<\/code><br \/>\nSave and exit by pressint CTRL + X and then pressing Y then ENTER.<\/p>\n<h4>Restart Apache service<\/h4>\n<p><code>sudo service apache2 restart<\/code><\/p>\n<h4>Accessing PHPMyAdmin<\/h4>\n<p>Type http:\/\/localhost\/phpmyadmin in browser<br \/>\nUser Name and Password are the ones set in previous step.<\/p>\n<h4>Install GEdit<\/h4>\n<p><code>sudo apt install gedit -y<\/code><\/p>\n<h4>Increase import file size of PHPMyAdmin<\/h4>\n<p><code>sudo gedit \/etc\/php\/7.3\/apache2\/php.ini<\/code><br \/>\nupdate the following values:<br \/>\n<code>memory_limit: 256M (default = 128)<\/code><br \/>\n<code>post_max_size: 64M<\/code><br \/>\n<code>upload_max_filesize: 40M<\/code><br \/>\nSave and exit.<br \/>\nRestart apache<br \/>\n<code>sudo \/etc\/init.d\/apache2 restart<\/code><\/p>\n<h4>Import Database<\/h4>\n<p>Create new database (match the database name in the backup sql file)<br \/>\nGo to Import tab (ignore errors), select backup sql file and import<\/p>\n<h4>&#8220;Install&#8221; WordPress<\/h4>\n<p>Copy from USB drive (files and folders under public_html folder\/) to \/var\/www\/html\/ folder<\/p>\n<h4>Edit &#8220;wp-config.php&#8221;<\/h4>\n<p>Open &#8220;wp-config.php&#8221; with Text Editor.<br \/>\nUpdate the following values:<br \/>\nDB_USER<br \/>\nDB_PASSWORD<br \/>\nAlso, add the following values:<br \/>\ndefine(&#8216;WP_SITEURL&#8217;, &#8216;http:\/\/www.hi-alex.com\/&#8217;);<br \/>\ndefine(&#8216;WP_HOME&#8217;, &#8216;http:\/\/www.hi-alex.com\/&#8217;);<\/p>\n<h4>Done<\/h4>\n<p>&nbsp;<\/p>\n<h4>Fixing phpmyadmin &#8220;phpmyadmin &#8211; count(): Parameter must be an array or an object that implements Countable&#8221; error:<\/h4>\n<p><code>sudo nano +613 \/usr\/share\/phpmyadmin\/libraries\/sql.lib.php<\/code><br \/>\nreplace code<\/p>\n<pre><code>((empty($analyzed_sql_results['select_expr']))\n    || (count($analyzed_sql_results['select_expr'] == 1)\n        &amp;&amp; ($analyzed_sql_results['select_expr'][0] == '*')))<\/code><\/pre>\n<p>with<\/p>\n<pre><code>((empty($analyzed_sql_results['select_expr']))\n    || (count($analyzed_sql_results['select_expr']) == 1)\n        &amp;&amp; ($analyzed_sql_results['select_expr'][0] == '*'))\n<\/code><\/pre>\n<p>Ctrl + O<br \/>\nEnter<br \/>\nCtrl + X<br \/>\n<code>sudo service apache2 restart<\/code><br \/>\n<code>sudo nano +613 \/usr\/share\/phpmyadmin\/libraries\/sql.lib.php<\/code><br \/>\nreplace code<\/p>\n<pre class=\"lang-sh prettyprint prettyprinted\"><code><span class=\"kwd\">if<\/span> <span class=\"pun\">(<\/span><span class=\"pln\">$options <\/span><span class=\"pun\">!=<\/span><span class=\"pln\"> null <\/span><span class=\"pun\">&amp;&amp;<\/span><span class=\"pln\"> count<\/span><span class=\"pun\">(<\/span><span class=\"pln\">$options<\/span><span class=\"pun\">)<\/span> <span class=\"pun\">&gt;<\/span> <span class=\"lit\">0<\/span><span class=\"pun\">)<\/span> <span class=\"pun\">{\n<\/span><\/code><\/pre>\n<p>with<\/p>\n<pre class=\"lang-sh prettyprint prettyprinted\"><code><span class=\"kwd\">if<\/span> <span class=\"pun\">(<\/span><span class=\"pln\">$options <\/span><span class=\"pun\">!=<\/span><span class=\"pln\"> null <\/span><span class=\"pun\">&amp;&amp;<\/span><span class=\"pln\"> count<\/span><span class=\"pun\">((<\/span><span class=\"pln\">array<\/span><span class=\"pun\">)<\/span><span class=\"pln\">$options<\/span><span class=\"pun\">)<\/span> <span class=\"pun\">&gt;<\/span> <span class=\"lit\">0<\/span><span class=\"pun\">)<\/span> <span class=\"pun\">{<\/span><\/code><\/pre>\n<p>Ctrl + O<br \/>\nEnter<br \/>\nCtrl + X<br \/>\n<code>sudo service apache2 restart<\/code><br \/>\n&nbsp;<\/p>\n<h4>Securing phpmyadmin, block access from internet<\/h4>\n<p><span style=\"font-family: georgia, palatino, serif;\">Open it in a text editor (<code>sudo nano \/etc\/phpmyadmin\/apache.conf<\/code>) and find the block that looks like:<\/span><\/p>\n<pre><span style=\"font-family: georgia, palatino, serif;\">&lt;Directory \/usr\/share\/phpmyadmin&gt;\n...\n&lt;\/Directory&gt;\n<\/span><\/pre>\n<p><span style=\"font-family: georgia, palatino, serif;\">Inside the block, add the following lines:<\/span><\/p>\n<pre><span style=\"font-family: georgia, palatino, serif;\">Order Deny,Allow\nDeny from all<\/span>\n<span style=\"font-family: georgia, palatino, serif;\">Allow from localhost\nAllow from 127.0.0.1\nAllow from 192.168.68.0\/24\n<\/span><\/pre>\n<p>Ctrl + O<br \/>\nEnter<br \/>\nCtrl + X<br \/>\n<code>sudo service apache2 restart<\/code><br \/>\n<span style=\"font-family: georgia, palatino, serif;\">&nbsp;<\/span><\/p>\n<h4>Map www.hi-alex.com to a sub folder under \/var\/www\/html\/<\/h4>\n<p><code>sudo nano \/etc\/apache2\/sites-enabled\/000-default.conf<\/code><br \/>\nAdd the following lines:<br \/>\n<code>ServerAdmin webmaster@localhost<\/code><br \/>\n<code>DocumentRoot \/var\/www\/html\/blog<\/code><br \/>\n<code>ServerName www.hi-alex.com<\/code><br \/>\nCtrl + O<br \/>\nEnter<br \/>\nCtrl + X<br \/>\n&nbsp;<\/p>\n<h4>References:<\/h4>\n<p><a href=\"https:\/\/opensource.com\/article\/18\/10\/setting-wordpress-raspberry-pi\">How to Install WordPress on Raspberry Pi<\/a><br \/>\n<a href=\"https:\/\/pimylifeup.com\/raspberry-pi-phpmyadmin\/\">How to Install phpmyadmin on Raspberry Pi<\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/a\/11646202\">Increase phpmyadmin import file size<\/a><br \/>\n<a href=\"https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=45607\">Mount ExFat disk on Raspberry Pi<\/a><br \/>\n<a href=\"https:\/\/www.tweaking4all.com\/web-development\/wordpress\/copy-or-move-wordpress-to-another-server\/\">Copy or Move WordPress to Another Server<\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/a\/49483740\">Fix phpmyadmin error<\/a><br \/>\n<a href=\"https:\/\/stackoverflow.com\/a\/59239717\">Fix phpmyadmin error on Import tab<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Preparation Take full backup of existing system Copy files to USB drive (extFat format) &nbsp; On Raspberry Pi: Update system sudo apt-get update sudo apt-get upgrade Mount USB Drive sudo apt install exfat-fuse exfat-utils Install Apache sudo apt install apache2 -y Install MariaDB sudo apt-get install mariadb-server -y Install PHP sudo apt-get install php php-mysql [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-3675","post","type-post","status-publish","format-standard","hentry","category-20"],"_links":{"self":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts\/3675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3675"}],"version-history":[{"count":0,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=\/wp\/v2\/posts\/3675\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3675"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hi-alex.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}