{"id":4145,"date":"2017-08-29T20:59:47","date_gmt":"2017-08-29T20:59:47","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2017\/08\/29\/lamp-centos-howto\/"},"modified":"2021-08-16T22:37:01","modified_gmt":"2021-08-17T02:37:01","slug":"how-to-install-lamp-stack-on-centos","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/","title":{"rendered":"How to Install LAMP Stack on CentOS"},"content":{"rendered":"<p>This guide will show you the steps needed to <strong>install a LAMP stack<\/strong> on your <strong>Cloud Server<\/strong> running CentOS. All the commands shown will need to be run as root on your server via SSH.<\/p>\n<h2>Installing LAMP stack on CentOS<\/h2>\n<ol class=\"article_list\">\n<li>Connect to your server as the <a href=\"https:\/\/www.inmotionhosting.com\/support\/amp\/obtain-root-access\/\">root<\/a> user via <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/ssh-advantages\/\">SSH<\/a>.<\/li>\n<li>Before installing we need to ensure your packages and repositories are up to date by running the following command. You will be prompted to continue after it has finished checking for updates by pressing <b>y<\/b> (yes) or <b>n<\/b> (no). Hit <b>y<\/b> and then <b>enter<\/b> to continue.\n<p class=\"cli\"><span style=\"color: #00e000;\">yum update<\/span><\/p>\n<\/li>\n<li>Apache uses port 80 for non-SSL traffic and 443 for SSL traffic. Both of these ports need to be open in the firewall. Run the following three commands to open them.\n<p class=\"cli\"><span style=\"color: #00e000;\">service firewalld start<br>firewall-cmd \u2013permanent \u2013zone=public \u2013add-service=http<br>firewall-cmd \u2013permanent \u2013zone=public \u2013add-service=https<br>firewall-cmd \u2013reload <\/span><\/p>\n<\/li>\n<li>Install Apache(httpd) by running the following command. You will be prompted to continue, press <b>y<\/b> for yes and hit <b>enter<\/b>.\n<p class=\"cli\"><span style=\"color: #00e000;\">yum install httpd<\/span><\/p>\n<p>After the install has finished you need to start the service by running the command below.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">systemctl start httpd.service<\/span><\/p>\n<\/li>\n<li>We will now install MariaDB (MySQL). MariaDB is the recommended service for MySQL currently included in the CentOS repositories.\n<p class=\"cli\"><span style=\"color: #00e000;\">yum install mariadb-server mariadb<\/span><\/p>\n<p>Before starting some edits are recommended to \/etc\/my.cnf to ensure safe limits for mysql by setting the below parameters.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">max_connections=8<br>thread_cache_size=2 <\/span><\/p>\n<p>Once installed and configured start the service by running the command below.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">systemctl start mariadb<\/span><\/p>\n<p>The default install of MySQL contains settings and users for testing that are not secure. To secure the installation run the command below. You will be asked if you want to set a root password for MariaDB and should press <b>y<\/b> and hit <b>enter<\/b> to continue. You will then be prompted to set a password for MariaDB, ensure this password is set to a strong password. After setting the password you will get more yes or no prompts. Just hit <b>enter<\/b> until you have completed the prompts. You will see the message \u201c<em>installation should now be secure. Thanks for using MariaDB!<\/em>\u201d When complete.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">mysql_secure_installation<\/span><\/p>\n<\/li>\n<li>Install PHP and some common extensions for PHP by running the following command. You may be prompted to press <b>y<\/b> and <b>enter<\/b> again.\n<p class=\"cli\"><span style=\"color: #00e000;\">yum install php70u php70u-mcrypt php70u-mbstring php70u-mysqlnd php70u-ioncube-loader php70u-soap php70u-common php70u-tidy php70u-pecl-imagick php70u-pspell php70u-pdo php70u-bcmath php70u-cli php70u-pear php70u-enchant php70u-xml php70u-pspell php70u-pear php70u-enchant php70u-xml php70u-pspell php70u-fpm php70u-fpm-httpd.noarch<\/span><\/p>\n<p>Once the install has finished restart Apache so it can use PHP and any installed modules using the command below.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">systemctl restart httpd.service<\/span><\/p>\n<p>Now we need to test PHP to ensure its working, You can run the following command to place a PHP info page in your document root.<\/p>\n<p class=\"cli\"><span style=\"color: #00e000;\">echo \u201c&lt;?php phpinfo();\u201d &gt; \/var\/www\/html\/phpinfo.php<\/span><\/p>\n<p>After running that command browse to https:\/\/yourservers_IP\/phpinfo.php. You should receive a page showing your PHP configuration information.<\/p>\n<\/li>\n<li>To ensure your services start automatically on reboot we need to enable them in Systemd(The software that manages services by default on CentOS). Run the following commands.\n<p class=\"cli\"><span style=\"color: #00e000;\">systemctl enable mariadb.service<br>systemctl enable httpd.service <\/span><\/p>\n<\/li>\n<\/ol>\n<p>Congratulations, you should now have a working LAMP stack! You now know how to <strong>install a LAMP stack<\/strong> on your <strong>Cloud Server<\/strong> running CentOS.<\/p>\n<p><img class=\"std_ss\" style=\"float: right; margin: 15px 15px 15px 15px;\" width=\"200\"><\/p>\n\n\n<p>Learn more from our <a href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/\">Cloud Server Hosting Product Guide<\/a>.<\/p>\n\n\n<div class=\"jumbotron\">\r\n<p>If you don\u2019t need cPanel, don't pay for it. Only pay for what you need with our scalable <a href=\"https:\/\/www.inmotionhosting.com\/cloud-vps\">Cloud VPS Hosting<\/a>.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>CentOS, Debian, or Ubuntu    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>No Bloatware    <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/design.inmotionhosting.com\/assets\/icons\/standard\/check-blue.svg\" alt=\"check mark\" width=\"24\" height=\"24\" \/>SSH and Root Access<\/p>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This guide will show you the steps needed to install a LAMP stack on your Cloud Server running CentOS. All the commands shown will need to be run as root on your server via SSH. Installing LAMP stack on CentOS Connect to your server as the root user via SSH. Before installing we need to<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\"> Read More ><\/a><\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4370],"tags":[],"class_list":["post-4145","post","type-post","status-publish","format-standard","hentry","category-cloud-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Install LAMP Stack on CentOS | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"Learn how to install LAMP stack on a Cloud VPS running CentOS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install LAMP Stack on CentOS | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Learn how to install LAMP stack on a Cloud VPS running CentOS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-29T20:59:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T02:37:01+00:00\" \/>\n<meta name=\"author\" content=\"Kyle McClammy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kyle McClammy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\"},\"author\":{\"name\":\"Kyle McClammy\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8c49132ed3eeb8593005b332e002c8b5\"},\"headline\":\"How to Install LAMP Stack on CentOS\",\"datePublished\":\"2017-08-29T20:59:47+00:00\",\"dateModified\":\"2021-08-17T02:37:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\"},\"wordCount\":586,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Cloud Server Hosting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\",\"name\":\"How to Install LAMP Stack on CentOS | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2017-08-29T20:59:47+00:00\",\"dateModified\":\"2021-08-17T02:37:01+00:00\",\"description\":\"Learn how to install LAMP stack on a Cloud VPS running CentOS.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install LAMP Stack on CentOS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8c49132ed3eeb8593005b332e002c8b5\",\"name\":\"Kyle McClammy\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/kylem\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Install LAMP Stack on CentOS | InMotion Hosting","description":"Learn how to install LAMP stack on a Cloud VPS running CentOS.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to Install LAMP Stack on CentOS | InMotion Hosting","og_description":"Learn how to install LAMP stack on a Cloud VPS running CentOS.","og_url":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2017-08-29T20:59:47+00:00","article_modified_time":"2021-08-17T02:37:01+00:00","author":"Kyle McClammy","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Kyle McClammy","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/"},"author":{"name":"Kyle McClammy","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8c49132ed3eeb8593005b332e002c8b5"},"headline":"How to Install LAMP Stack on CentOS","datePublished":"2017-08-29T20:59:47+00:00","dateModified":"2021-08-17T02:37:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/"},"wordCount":586,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Cloud Server Hosting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/","url":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/","name":"How to Install LAMP Stack on CentOS | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2017-08-29T20:59:47+00:00","dateModified":"2021-08-17T02:37:01+00:00","description":"Learn how to install LAMP stack on a Cloud VPS running CentOS.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/product-guides\/cloud-server\/how-to-install-lamp-stack-on-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Install LAMP Stack on CentOS"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/8c49132ed3eeb8593005b332e002c8b5","name":"Kyle McClammy","url":"https:\/\/www.inmotionhosting.com\/support\/author\/kylem\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=4145"}],"version-history":[{"count":7,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4145\/revisions"}],"predecessor-version":[{"id":83869,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4145\/revisions\/83869"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=4145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=4145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=4145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}