{"id":31,"date":"2016-12-05T19:45:00","date_gmt":"2016-12-05T19:45:00","guid":{"rendered":"\/colin\/morethanfour\/post\/Setting-up-a-LAMP-test-environment"},"modified":"2016-12-05T19:45:00","modified_gmt":"2016-12-05T19:45:00","slug":"setting-up-a-lamp-test-environment","status":"publish","type":"post","link":"https:\/\/spacefold.com\/colin\/morethanfour\/2016\/12\/05\/setting-up-a-lamp-test-environment\/","title":{"rendered":"Setting up a LAMP test environment"},"content":{"rendered":"<p>Not my usual kind of thing, but a possible new client meant preparing a system to stand up a replica of their production environment. These are my notes.<\/p>\n<p>I started by downloading an .iso of ubuntu-12.04-server and deploying it to a new VM.<\/p>\n<p>Critical things to remember:<\/p>\n<ul>\n<li>Set up two network adapters in the virtual machine config: NAT, and Host-only networking, as per my notes documented elsewhere;<\/li>\n<li>select [X] LAMP server during the deployment to give it Apache\/MySQL\/PHP in one hit, at startup;<\/li>\n<li>install ssh so you can remote into it<\/li>\n<\/ul>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo apt-get install openssh-server openssh-client<\/pre>\n<p><\/div>\n<p>Checking for installed status:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ which php<br>\/usr\/bin\/php<br> <br>$ sudo service apache2 status<br>[sudo] password <span style=\"color: #0000ff\">for<\/span> colin: ****<br>Apache2 is running (pid 1107).<br> <br>$ mysql -u root -p<br>Enter password: ****<br>..<br>mysql&gt;<\/pre>\n<p><\/div>\n<p>By default, the Apache web server document root folder appears to be:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ ls -l \/var\/www<br>total 4<br>-rw-r--r-- 1 root root 177 Dec 6 12:10 index.html<br>$<\/pre>\n<p><\/div>\n<h3>Allowing connections to MySQL from outside the server<\/h3>\n<p>Edit \/etc\/mysql\/my.conf:<\/p>\n<p>Comment out the line:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">#bind-address    = 127.0.0.1<\/pre>\n<p><\/div>\n<p>Run the following SQL(might not be required, note the 0 rows affected):<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">mysql&gt; grant all privileges on *.* to <span style=\"color: #006080\">'root'<\/span>@<span style=\"color: #006080\">'%'<\/span> identified by <span style=\"color: #006080\">'****'<\/span> with grant option;<br>Query OK, 0 rows affected (0.00 sec)<br> <br>mysql&gt; flush privileges;<br>Query OK, 0 rows affected (0.00 sec)<\/pre>\n<p><\/div>\n<p>Restart the DB:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo service mysql stop<br>mysql stop\/waiting<br> <br>$ sudo service mysql start<br>mysql start\/running, <span style=\"color: #0000ff\">process<\/span> 1578<\/pre>\n<p><\/div>\n<p>And, importantly, test from outside (in my case, my host operating system):<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin&gt; mysql -h 192.168.56.56 -u root -p<br>Enter password: ****<br>...<br>mysql&gt;<\/pre>\n<p><\/div>\n<p>In MySQL Workbench:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"display: inline\" alt=\"image\" src=\"http:\/\/www.spacefold.com\/colin\/morethanfour\/wp-content\/uploads\/image_6.png\" width=\"628\" height=\"365\"><\/p>\n<p>Cool.<\/p>\n<h3>Installing FTP server<\/h3>\n<p>Just in case we need to move files in and out of the test environment (which we almost certainly will need to do), we&#8217;ll set up an FTP server. The most suggested option seems to be something called <strong>vsftpd<\/strong>:<\/p>\n<p>Reference:  <a title=\"https:\/\/www.liquidweb.com\/kb\/how-to-install-and-configure-vsftpd-on-ubuntu-12-04-lts\/\" href=\"https:\/\/www.liquidweb.com\/kb\/how-to-install-and-configure-vsftpd-on-ubuntu-12-04-lts\/\">https:\/\/www.liquidweb.com\/kb\/how-to-install-and-configure-vsftpd-on-ubuntu-12-04-lts\/<\/a><\/p>\n<p>When I tried this, I got an error:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo apt-get install vsftpd<br>[sudo] password <span style=\"color: #0000ff\">for<\/span> colin: ***<br>Reading package lists... Done<br>Building dependency tree<br>Reading state information... Done<br>Package vsftpd is not available, but is referred to by another package.<br>This may mean that the package is missing, has been obsoleted, or<br>is only available from another source<br> <br>E: Package <span style=\"color: #006080\">'vsftpd'<\/span> has no installation candidate<\/pre>\n<p><\/div>\n<p>Long story short, the following sequence of instructions worked for me:<\/p>\n<p>1. un-comment the extras.ubuntu.com repositories in \/etc\/apt\/sources.list:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\"><span style=\"color: #008000\">## Uncomment the following two lines to add software from Ubuntu's<\/span><br><span style=\"color: #008000\">## 'extras' repository.<\/span><br><span style=\"color: #008000\">## This software is not part of Ubuntu, but is offered by third-party<\/span><br><span style=\"color: #008000\">## developers who want to ship their latest software.<\/span><br>deb http:\/\/extras.ubuntu.com\/ubuntu precise main<br>deb-src http:\/\/extras.ubuntu.com\/ubuntu precise main<\/pre>\n<p><\/div>\n<p>2. Remove old information, and update:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo rm -rf \/var\/lib\/apt\/lists\/*<br>$ sudo apt-get update<\/pre>\n<p><\/div>\n<p>3. try installing again:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo apt-get install vsftpd<br>Reading package lists... Done<br>Building dependency tree<br>Reading state information... Done<br>The following NEW packages will be installed:<br>  vsftpd<br>0 upgraded, 1 newly installed, 0 to remove and 129 not upgraded.<br>Need to get 124 kB of archives.<br>After this operation, 342 kB of additional disk space will be used.<br>Get:1 http:\/\/us.archive.ubuntu.com\/ubuntu\/ precise\/main vsftpd amd64 2.3.5-1ubuntu2 [124 kB]<br>Fetched 124 kB <span style=\"color: #0000ff\">in<\/span> 1s (91.2 kB\/s)<br>Preconfiguring packages ...<br>Selecting previously unselected package vsftpd.<br>(Reading database ... 53560 files and directories currently installed.)<br>Unpacking vsftpd (from ...\/vsftpd_2.3.5-1ubuntu2_amd64.deb) ...<br>Processing triggers <span style=\"color: #0000ff\">for<\/span> man-db ...<br>Processing triggers <span style=\"color: #0000ff\">for<\/span> ureadahead ...<br>Setting up vsftpd (2.3.5-1ubuntu2) ...<br>vsftpd start\/running, <span style=\"color: #0000ff\">process<\/span> 2229<br>$<\/pre>\n<p><\/div>\n<p>Thank goodness for that!<\/p>\n<p>Some configuration required in \/etc\/vsftpd.conf, see:<\/p>\n<ul>\n<li><a title=\"http:\/\/www.krizna.com\/ubuntu\/setup-ftp-server-on-ubuntu-14-04-vsftpd\/\" href=\"http:\/\/www.krizna.com\/ubuntu\/setup-ftp-server-on-ubuntu-14-04-vsftpd\/\">http:\/\/www.krizna.com\/ubuntu\/setup-ftp-server-on-ubuntu-14-04-vsftpd\/<\/a><\/li>\n<\/ul>\n<p>basically<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">write_enable=YES<br>local_umask=022<\/pre>\n<p><\/div>\n<p>Restart:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">$ sudo service vsftpd restart<br>vsftpd stop\/waiting<br>vsftpd start\/running, <span style=\"color: #0000ff\">process<\/span> 2462<br>$<\/pre>\n<p><\/div>\n<p>Now, testing from the Windows host:<\/p>\n<div id=\"codeSnippetWrapper\">\n<pre id=\"codeSnippet\" style=\"border-top-style: none; font-size: 8pt; overflow: visible; border-left-style: none; font-family: 'Courier New', courier, monospace; width: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; background-color: #f4f4f4\">C:\\PROGRA~2\\WinSCP&gt;WinSCP<br>winscp&gt; open 192.168.56.56<br>Searching <span style=\"color: #0000ff\">for<\/span> host...<br>Connecting to host...<br>Authenticating...<br>Username: colin<br>Password: ****<br>Authenticated.<br>Starting the session...<br>Session started.<br>Active session: [1] 192.168.56.56<br>winscp&gt;<\/pre>\n<p><\/div>\n<p>OK, I think it is all ready for us to unpack that archive we got from the client and see about deploying into the test environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not my usual kind of thing, but a possible new client meant preparing a system to stand up a replica of their production environment. These are my notes. I started by downloading an .iso of ubuntu-12.04-server and deploying it to a new VM. Critical things to remember: Set up two network adapters in the virtual [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-linux","post-preview"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/comments?post=31"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/media?parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/categories?post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/colin\/morethanfour\/wp-json\/wp\/v2\/tags?post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}