{"id":5003,"date":"2014-05-21T00:24:42","date_gmt":"2014-05-20T16:24:42","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=5003"},"modified":"2023-06-01T14:39:30","modified_gmt":"2023-06-01T14:39:30","slug":"how-to-install-and-configure-apache2-php-and-mysql-5-6-on-ubuntu-14-04","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-configure-apache2-php-and-mysql-5-6-on-ubuntu-14-04\/","title":{"rendered":"How to Install and Configure Apache2, PHP and MySQL 5.6 on Ubuntu 14.04"},"content":{"rendered":"<p>LAMP stack is a group of open source software that installed together to let you run a server to host dynamic websites. &#8220;L&#8221; stand for Linux, &#8220;A&#8221; stand for <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a> (to host Web server), &#8220;M&#8221; stand for MySQL(to store database) and &#8220;P&#8221; stand for PHP(to process dynamic content). With the release of Ubuntu 14.04 on April 17 2014, i would share the steps to setup Apache2, PHP and MySQL on Ubuntu 14.04 in order to run a dynamic websites. This may useful for those who plan to run their websites on Virtual private server (VPS) or dedicated server.<\/p>\n<p>1. Install Apache2, MySQL and PHP :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo apt-get install apache2 php5 php5-cgi libapache2-mod-php5 php5-common php-pear mysql-server-5.6 -y\r\n<\/pre>\n<p>During this installation, you will require to set MySQL&#8217;s root password :<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/1.png\" alt=\"1\" width=\"564\" height=\"291\" class=\"alignnone size-full wp-image-5108 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/1.png 564w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/1-300x155.png 300w\" data-sizes=\"(max-width: 564px) 100vw, 564px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 564px; --smush-placeholder-aspect-ratio: 564\/291;\" \/><\/p>\n<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/2.png\" alt=\"2\" width=\"483\" height=\"249\" class=\"alignnone size-full wp-image-5109 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/2.png 483w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2014\/05\/2-300x155.png 300w\" data-sizes=\"(max-width: 483px) 100vw, 483px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 483px; --smush-placeholder-aspect-ratio: 483\/249;\" \/><\/p>\n<p>2. Backup the original Apache2 configuration file :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo cp -p \/etc\/apache2\/conf-enabled\/security.conf \/etc\/apache2\/conf-enabled\/security.conf.bak\r\n<\/pre>\n<p>3. Open security.conf and modify the OS to become Prod. For security reason, Prod will tells apache to only return Apache in the Server header, returned on every page request.<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/apache2\/conf-enabled\/security.conf\r\n<\/pre>\n<pre>\r\n..\r\n..\r\nServerTokens Prod\r\n..\r\n..\r\nServerSignature Off\r\n..\r\n..\r\n<\/pre>\n<p>4. Add file extension that can be access :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/apache2\/mods-enabled\/dir.conf\r\n<\/pre>\n<pre>\r\n&lt;IfModule mod_dir.c&gt;\r\n        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm\r\n&lt;\/IfModule&gt;\r\n<\/pre>\n<p>5. Specify server name :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/apache2\/apache2.conf\r\n<\/pre>\n<pre>\r\n# Do NOT add a slash at the end of the directory path.\r\n#\r\n#ServerRoot \"\/etc\/apache2\"\r\nServerName ubuntu14.ehowstuff.local\r\n#\r\n# The accept se\r\n<\/pre>\n<p>6. Specify webmaster&#8217;s email :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/apache2\/sites-enabled\/000-default.conf\r\n<\/pre>\n<pre>\r\n\r\n        ServerAdmin webmaster@ubuntu14.ehowstuff.local\r\n        DocumentRoot \/var\/www\/html\r\n\r\n<\/pre>\n<p>7. Restart web server apache2 :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo \/etc\/init.d\/apache2 restart\r\n * Restarting web server apache2                                                             [ OK ]\r\n<\/pre>\n<p>8. Near line 220: add extension for PHP :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/apache2\/mods-enabled\/mime.conf\r\n<\/pre>\n<pre>\r\n..\r\n..\r\nAddHandler php5-script .php\r\n..\r\n..\r\n<\/pre>\n<p>9. Comment and add your timezone :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo vi \/etc\/php5\/apache2\/php.ini\r\n<\/pre>\n<pre>\r\n..\r\n..\r\ndate.timezone = \"Asia\/Kuala Lumpur\"\r\n..\r\n..\r\n<\/pre>\n<p>After change php.ini, restart the apache :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo \/etc\/init.d\/apache2 restart\r\n * Restarting web server apache2                                                             [ OK ]\r\n<\/pre>\n<p>10. Connect to MySQL :<\/p>\n<pre>\r\nehowstuff@ubuntu14:~$ sudo mysql -u root -p\r\nEnter password:\r\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\r\nYour MySQL connection id is 36\r\nServer version: 5.6.17-0ubuntu0.14.04.1 (Ubuntu)\r\n\r\nCopyright (c) 2000, 2014, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nOracle is a registered trademark of Oracle Corporation and\/or its\r\naffiliates. Other names may be trademarks of their respective\r\nowners.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nmysql>\r\n<\/pre>\n<p>11. Show user info :<\/p>\n<pre>\r\nmysql> select user,host,password from mysql.user;\r\n+------------------+-----------+-------------------------------------------+\r\n| user             | host      | password                                  |\r\n+------------------+-----------+-------------------------------------------+\r\n| root             | localhost | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n| root             | ubuntu14  | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n| root             | 127.0.0.1 | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n| root             | ::1       | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 |\r\n| debian-sys-maint | localhost | *9C063813F4CC3C2E09995B0D043C7375C5E5538A |\r\n+------------------+-----------+-------------------------------------------+\r\n5 rows in set (0.00 sec)\r\n<\/pre>\n<p>12. Show databases :<\/p>\n<pre>\r\nmysql> show databases;\r\n+--------------------+\r\n| Database           |\r\n+--------------------+\r\n| information_schema |\r\n| mysql              |\r\n| performance_schema |\r\n+--------------------+\r\n3 rows in set (0.01 sec)\r\n\r\n<\/pre>\n<p>Done!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LAMP stack is a group of open source software that installed together to let you run a server to host dynamic websites. &#8220;L&#8221; stand for Linux, &#8220;A&#8221; stand for Apache&#8230;<\/p>\n","protected":false},"author":6,"featured_media":5110,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1103,1008,1025],"tags":[1199,1536,1585,1646,1856,1858],"class_list":["post-5003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache","category-mysql","category-php","tag-apache","tag-linux","tag-mysql","tag-php","tag-ubuntu","tag-ubuntu-14-04"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=5003"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5003\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/5110"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=5003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=5003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=5003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}