{"id":11225,"date":"2023-08-03T14:16:00","date_gmt":"2023-08-03T13:16:00","guid":{"rendered":"https:\/\/www.20i.com\/blog\/?p=11225"},"modified":"2025-10-22T12:15:14","modified_gmt":"2025-10-22T11:15:14","slug":"install-lamp-stack-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.20i.com\/blog\/install-lamp-stack-on-ubuntu\/","title":{"rendered":"How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04\u00a0\u00a0"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Welcome to our step-by-step guide on setting up a Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This combination of technologies forms a powerful web server framework that can host dynamic websites and web applications. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Installing a LAMP stack can seem a bit daunting, especially if you&#8217;re new to server administration and web development. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fear not! <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This tutorial is designed to guide you through the process, making it as seamless and understandable as possible. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By the time you finish, you&#8217;ll have a robust platform ready to support your web projects. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Whether you&#8217;re an experienced developer or a newcomer to the world of <a href=\"https:\/\/www.20i.com\/web-hosting\" data-internallinksmanager029f6b8e52c=\"16\" title=\"web hosting\">web hosting<\/a>, let&#8217;s dive in!<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li><strong>Install Apache<\/strong>&nbsp;<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the terminal and update the package index by running the command: <\/li>\n\n\n\n<li>Then install Apache by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update&nbsp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then install Apache by running the command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2&nbsp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After the installation is complete, you can start the Apache service by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start apache2 <\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can also configure Apache to start automatically on boot:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code> sudo systemctl enable apache2&nbsp;<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Install MySQL<\/strong>&nbsp;<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install MySQL by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install mysql-server&nbsp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>During the installation process, you may be prompted to set a root password for MySQL but it will possibly pick up on the root password for your server.&nbsp; After the installation is complete, you can start the MySQL service by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start mysql<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can also configure MySQL to start automatically on boot: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable mysql<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>Install PHP:<\/strong>&nbsp;<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install PHP and the necessary modules by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php libapache2-mod-php php-mysql&nbsp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After the installation is complete, you will need to configure Apache to use PHP. To do this, open the Apache configuration file by running the command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/apache2\/mods-enabled\/dir.conf <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the changes and exit the editor.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Press:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Esc shift +<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wq&nbsp;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, restart the Apache service by running the command: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart apache2&nbsp;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test your LAMP stack:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To test if the LAMP stack is working properly, create a new PHP file in the Apache web root directory by running the command: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/var\/www\/html\/info.php&nbsp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add the following line of code to the file: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php phpinfo(); ?&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Save the changes and exit the editor.&nbsp;<\/li>\n\n\n\n<li>Then, in your web browser, navigate to &#8220;http:\/\/your_server_ip\/info.php&#8221;&nbsp;<\/li>\n\n\n\n<li>If everything is set up correctly, you should see a page displaying information about your PHP installation.&nbsp;<\/li>\n<\/ul>\n\n\n<div class='code-block code-block-10' style='margin: 8px 0; clear: both;'>\n<hr>\n<br \/>\n<p><strong>Deploy all your apps with great value virtual server hosting, no compromises.<\/strong> Our high-performance VPS include:<\/p>\n<ul>\n<li>Lightning-fast speed with 100% SSD storage<\/li>\n<li>Genuine unlimited bandwidth \u2013 no throttling, ever<\/li>\n<li>Deploy standard distro, 1-click app or custom image<\/li>\n<li>Manage your servers through one single, intuitive control panel<\/li>\n<li>100% green hosting powered by renewable energy<\/li>\n<\/ul>\n<p>Find out how our <a href=\"https:\/\/www.20i.com\/vps\">VPS Hosting<\/a> is the perfect choice, from personal projects to complex apps. Visitors outside the UK can view our <a href=\"https:\/\/www.20i.com\/us\/vps\">VPS Hosting<\/a> here.<\/p>\n<br \/><br \/><\/div>\n\n","protected":false},"excerpt":{"rendered":"Welcome to our step-by-step guide on setting up a Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04.&hellip;","protected":false},"author":25,"featured_media":17255,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ub_ctt_via":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[47],"tags":[94,79],"class_list":["post-11225","post","type-post","status-publish","format-standard","has-post-thumbnail","category-web-hosting","tag-open-source","tag-web-development","cs-entry"],"featured_image_src":"https:\/\/www.20i.com\/blog\/wp-content\/uploads\/2025\/10\/How-to-install-linux-apache-mysql-phplamp-stack-on-ubuntu-scaled.png","author_info":{"display_name":"Ben Perry","author_link":"https:\/\/www.20i.com\/blog\/author\/benperry92\/"},"_links":{"self":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/comments?post=11225"}],"version-history":[{"count":11,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11225\/revisions"}],"predecessor-version":[{"id":11262,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/posts\/11225\/revisions\/11262"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media\/17255"}],"wp:attachment":[{"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/media?parent=11225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/categories?post=11225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.20i.com\/blog\/wp-json\/wp\/v2\/tags?post=11225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}