{"id":19,"date":"2015-12-25T14:21:50","date_gmt":"2015-12-25T14:21:50","guid":{"rendered":"http:\/\/www.gts-ltd.co.uk\/wordpress\/?p=19"},"modified":"2015-12-25T14:41:53","modified_gmt":"2015-12-25T14:41:53","slug":"installing-lamp-linux-apache-mysql-and-php-on-linux-mint-17-3","status":"publish","type":"post","link":"https:\/\/www.gts-ltd.co.uk\/wordpress\/2015\/12\/25\/installing-lamp-linux-apache-mysql-and-php-on-linux-mint-17-3\/","title":{"rendered":"Installing LAMP (Linux, Apache, MySQL and PHP) On Linux Mint 17.3"},"content":{"rendered":"<p>If you&#8217;re a website designer who uses PHP, mySQL and Apache to build sites, you&#8217;ll need to install these applications on your computer in order to run your sites locally. I recently set up a Linux machine with Mint 17.3 and Mate, and found that the <a href=\"http:\/\/community.linuxmint.com\/tutorial\/view\/486\">tutorial I followed<\/a>\u00a0was very helpful but missed out a few items which it took me some time to figure out.<\/p>\n<p>What follows is\u00a0a slightly modified tutorial which describes\u00a0what worked for me.<!--more--><\/p>\n<h2>Install Apache<\/h2>\n<p>Begin by installing the Apache web server.<\/p>\n<ol>\n<li>Open the Terminal, either by clicking the shortcut at the bottom left of the screen, or by clicking Menu &gt; Applications &gt; System Tools\u00a0&gt; Terminal.<\/li>\n<li>Copy\/Paste or type the following line of code into Terminal and then press Enter:<\/li>\n<\/ol>\n<pre>sudo apt-get install apache2<\/pre>\n<ol start=\"3\">\n<li>The Terminal will ask for your password, type it and then press Enter.<\/li>\n<\/ol>\n<h2>Testing Apache<\/h2>\n<ol>\n<li>Open a web browser and enter the following web address:<\/li>\n<\/ol>\n<pre>http:\/\/localhost\/<\/pre>\n<p>This should show you a default web page which says &#8220;It works&#8221; and gives information about Apache.<\/p>\n<h2>File location and permissions<\/h2>\n<p>Any web files you want to view in a browser should be placed in the following folder:<\/p>\n<pre>\/var\/www\/html<\/pre>\n<p>For example if you put a file<strong> index.php<\/strong> into<strong> \/var\/www\/html<\/strong>, you can browse to it at localhost\/index.php.<\/p>\n<p>The var folder is at the root of the file system and is owned by root, not by the username with which you logged in to the computer.\u00a0This means that\u00a0only the root user can edit files in the <strong>html<\/strong> folder. Don&#8217;t worry, you can change this.<\/p>\n<p>You can right-click on the <strong>html<\/strong> folder in Explorer and choose &#8220;Open as administrator&#8221;, and then you&#8217;ll be able to edit files in the folder. However this won&#8217;t allow Fireftp or other software installed by you to edit the files, so it&#8217;s not the best solution.<\/p>\n<p>Instead, make yourself\u00a0the owner of the <strong>html<\/strong> folder. You can do this through the GUI:<\/p>\n<ol>\n<li>Open the folder as administrator.<\/li>\n<li>Right-click the HTML folder and choose Properties.<\/li>\n<li>Choose the Permissions tab.<\/li>\n<li>Change Owner to be your username.<\/li>\n<\/ol>\n<p>This is fine if you have not yet added any files or subfolders to <strong>html<\/strong>. However if you have added content to the <strong>html<\/strong> folder, you will need to change the owner recursively and the GUI button for this &#8220;Apply permissions to Enclosed Files&#8221; doesn&#8217;t work. This seems to be a <a href=\"http:\/\/forums.linuxmint.com\/viewtopic.php?f=55&amp;t=27279&amp;p=158834&amp;hilit=fred+numerical\">known bu<\/a>g and it is not clear\u00a0to me why it has not been either fixed or the button removed. Fortunately the command line interface (CLI) is reasonably easy to use.<\/p>\n<ol>\n<li>In Terminal, enter the following code:<\/li>\n<\/ol>\n<pre>sudo chown yourusername \/var\/www\/html -R<\/pre>\n<p>This will recursively make you\u00a0the owner of <strong>html<\/strong>\u00a0and all the files and folders it contains. Test this by opening <strong>html<\/strong> in file explorer without choosing &#8220;Open as administrator&#8221; and check that you can create a blank file.<\/p>\n<h2>Install PHP<\/h2>\n<p>The next step is to install PHP 5.<\/p>\n<ol>\n<li>Enter the following code\u00a0into Terminal:<\/li>\n<\/ol>\n<pre>sudo apt-get install php5 libapache2-mod-php5<\/pre>\n<ol start=\"2\">\n<li>Restart Apache by entering the following code into Terminal:<\/li>\n<\/ol>\n<pre>sudo \/etc\/init.d\/apache2 restart<\/pre>\n<h2>Test PHP<\/h2>\n<p>Create a test PHP file and open it in a browser.<\/p>\n<ol>\n<li>If you have the text editor &#8216;gedit&#8217; installed, you can enter the following code in Terminal:<\/li>\n<\/ol>\n<pre>sudo gedit \/var\/www\/html\/testphp.php<\/pre>\n<p>However this doesn&#8217;t test whether you&#8217;ve correctly set the permissions on the html file, and you may not have gedit on your system. So instead, you can do this:<\/p>\n<ol>\n<li>Open the file explorer and browse to <strong>\/var\/www\/html<\/strong><\/li>\n<li>Create a new file <strong>testphp.php<\/strong><\/li>\n<li>Open your new file in a text editor.<\/li>\n<li>However you created <strong>testphp.php<\/strong>, now enter the following text and save the file:<\/li>\n<\/ol>\n<pre>&lt;?php phpinfo(); ?&gt;<\/pre>\n<ol start=\"5\">\n<li>In a web browser, navigate to the following web address:<\/li>\n<\/ol>\n<pre>http:\/\/localhost\/testphp.php<\/pre>\n<p>This should show a page with information about your php, confirming that you&#8217;ve installed both Apache and PHP.<\/p>\n<h2>Install MySQL<\/h2>\n<p>MySQL is the last element that will allow you to test sites built with MySQL, such as WordPress sites.<\/p>\n<ol>\n<li>In Terminal enter this code:<\/li>\n<\/ol>\n<pre>sudo apt-get install mysql-server<\/pre>\n<ol start=\"2\">\n<li>Optionally, configure your system so other computers on your network can view the server you have created. First open the file <strong>\/etc\/mysql\/my.cnf<\/strong>. Remember to open the containing folder as administrator so you can edit the file.<\/li>\n<li>Find this line in the file:<\/li>\n<\/ol>\n<pre>bind-address = 127.0.0.1<\/pre>\n<ol start=\"4\">\n<li>Change 127.0.0.1 to your IP address (type ifconfig in Terminal to find our your IP address).<\/li>\n<li>Save the file.<\/li>\n<\/ol>\n<p>You may have been asked to specify a password for MySQL in the install stage, but<strong> if you did not<\/strong>, you can <strong>set the password<\/strong> by entering the following code in Terminal:<\/p>\n<pre>mysql -u rootmysql&gt;<\/pre>\n<pre>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');<\/pre>\n<p>Replace &#8216;yourpassword&#8217; with a password of your choice.<\/p>\n<h2>Install phpMyAdmin<\/h2>\n<p>phpMyAdmin is a web interface for editing your MySQL databases.<\/p>\n<ol>\n<li>To install phpMyAdmin, enter the following code in Terminal:<\/li>\n<\/ol>\n<pre>sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin<\/pre>\n<ol start=\"2\">\n<li>To make PHP work with MySQL, first open the file <strong>\/etc\/php5\/apache2\/php.ini<\/strong>.<\/li>\n<li>Find the following line in the file (there may be spaces after the semicolon):<\/li>\n<\/ol>\n<pre>;extension=mysql.so<\/pre>\n<ol start=\"3\">\n<li>Uncomment the line by removing the semicolon so it looks like this:<\/li>\n<\/ol>\n<pre>extension=mysql.so<\/pre>\n<ol start=\"4\">\n<li>Now restart Apache again:<\/li>\n<\/ol>\n<pre>sudo \/etc\/init.d\/apache2 restart<\/pre>\n<ol start=\"5\">\n<li>In a browser, visit this URL:<\/li>\n<\/ol>\n<pre>http:\/\/localhost\/phpmyadmin<\/pre>\n<ol start=\"6\">\n<li>If you get a 404 error you need to configure Apache to work with\u00a0phpMyAdmin. Open the file <strong>\/etc\/apache2\/apache2.config<\/strong>.<\/li>\n<li>Add the following line at the bottom of the file and save it:<\/li>\n<\/ol>\n<pre>Include \/etc\/phpmyadmin\/apache.conf<\/pre>\n<ol start=\"7\">\n<li>Restart Apache again and fingers crossed, it will all work:<\/li>\n<\/ol>\n<pre>sudo \/etc\/init.d\/apache2 restart<\/pre>\n<p>Congratulations! You&#8217;re now ready to\u00a0develop websites with PHP and MySQL.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re a website designer who uses PHP, mySQL and Apache to build sites, you&#8217;ll need to install these applications on your computer in order to run your sites locally. I recently set up a Linux machine with Mint 17.3 and Mate, and found that the tutorial I followed\u00a0was very helpful but missed out a &hellip; <a href=\"https:\/\/www.gts-ltd.co.uk\/wordpress\/2015\/12\/25\/installing-lamp-linux-apache-mysql-and-php-on-linux-mint-17-3\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Installing LAMP (Linux, Apache, MySQL and PHP) On Linux Mint 17.3<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[9,7,8,10,11,3],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-tutorial","tag-apache","tag-lamp","tag-linux-mint-17-3","tag-mysql","tag-phpmyadmin","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":7,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":28,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/posts\/19\/revisions\/28"}],"wp:attachment":[{"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gts-ltd.co.uk\/wordpress\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}