{"id":1158,"date":"2020-08-21T16:14:22","date_gmt":"2020-08-21T16:14:22","guid":{"rendered":"https:\/\/hostingspell.com\/blog\/?p=1158"},"modified":"2020-08-21T16:14:22","modified_gmt":"2020-08-21T16:14:22","slug":"how-to-installing-lamp-stack-on-centos","status":"publish","type":"post","link":"https:\/\/blog.hostingspell.com\/how-to-installing-lamp-stack-on-centos\/","title":{"rendered":"How to &#8211; Installing LAMP Stack on CentOS"},"content":{"rendered":"\n<p style=\"color:#0d6d96\" class=\"has-text-color wp-block-paragraph\">If you have reached this page then you most likely know about a LAMP stack.<\/p>\n\n\n\n<p style=\"color:#146b90\" class=\"has-text-color wp-block-paragraph\">LAMP stack is a group of basic applications that most websites running on a Linux server are served. LAMP stands for Linux, Apache, MySQL\/ MariaDB and PHP.<\/p>\n\n\n\n<p style=\"color:#14688d\" class=\"has-text-color wp-block-paragraph\">With this article, let us learn how to install this LAMP stack on CentOS. This will help you run your website from any VPS.<\/p>\n\n\n\n<p class=\"has-text-color has-theme-primary-color wp-block-paragraph\"><strong><em>Prerequisite <\/em><\/strong>\u2013 the latest version of CentOS!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let us dive in!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">INSTALLING APACHE WEB SERVER<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">All you need to install the Apache web server is to type in this command in the terminal :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install httpd httpd-tools<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once this is done, let us move on to starting the Apache web server :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure you enable Apache to auto start at system boot time with this command :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable httpd<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-theme-primary-color wp-block-paragraph\">Status check :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you notice <strong><em>Enabled <\/em><\/strong>in the output, then Apache is running and will auto-start at boot time. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To test if Apache is running steadily, create an <code>index.html<\/code> file under the default document root with this below command : <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"Welcome to this site!\" &gt; \/var\/www\/html\/index.html<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, type 127.0.0.1 or <code>localhost<\/code> in your browser address bar. You should be able to see the welcome message from before. This means Apache web server is running without any problem!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">INSTALLING MySQL\/MariaDB<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To handle your website database you need to install MySQL or MariaDB. Since MariaDB is becoming more widely used, let use it for installation. MariaDB and MySQL are both similar in configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install MariaDB, type in the following command :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install mariadb-server\nsystemctl start mariadb \n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let us now enable MariaDB to auto start when the server starts :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable mariadb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some important server locations to be remembered for MariaDB\/ MySQL. These defaults can be changed to your preference. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>MariaDB binary: \/bin\/mysql\nMariaDB Configuration file: \/etc\/my.cnf\nDatabase location: \/var\/lib\/mysql\nMariaDB logs: \/var\/log\/mariadb\/mariadb.log\n<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-theme-primary-color wp-block-paragraph\">Status check :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status mariadb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At this point we need to run the security script :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql_secure_installation<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The output will ask you to enter your MariaDB root password. Since the root password isn\u2019t set yet, press the <em><strong>Enter<\/strong> <\/em>key. Then type <strong><em>y <\/em><\/strong>to set a new root password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After this, press<strong> <em>Enter<\/em><\/strong><em> <\/em>for all the remaining questions. This is a basic step in database security.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, run the following command to enter the MariaDB root password and log in to the MariaDB shell :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">INSTALLING PHP<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To install PHP and modules, type in this command :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install php php-fpm php-mysqlnd php-opcache php-gd php-xml php-mbstring -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So, Apache by default uses PHP-FPM instead of mod_php on centos to run a PHP code. With the help of the above command, we have also installed PHP-FPM. All we need to do is start it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start php-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to enable it to auto start at system boot time :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable php-fpm<\/code><\/pre>\n\n\n\n<p class=\"has-text-color has-theme-primary-color wp-block-paragraph\">Status check :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl status php-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the output shows <strong><em>enabled <\/em><\/strong>then PHP-FPM id up and running. Since PHP-FPM package installs a php.config file we need to restart Apache web server to run the PHP code :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart httpd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We also need to run the following command so that SELinux can allow Apache to execute the PHP code via PHP-FPM :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setsebool -P httpd_execmem 1<\/code><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\"><em>A<\/em><strong><em>ND CONCLUSION\u2026<\/em><\/strong><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Give yourself a pat on the back because you have successfully installed the AMP of LAMP Stack!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>We hope this article helped. <\/em><\/p>\n\n\n\n<p style=\"color:#1e8f14\" class=\"has-text-color wp-block-paragraph\"><em>Do share your thoughts!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have reached this page then you most likely know about a LAMP stack. LAMP stack is a group of basic applications that most websites running on a Linux server are served. LAMP stands for Linux, Apache, MySQL\/ MariaDB and PHP. With this article, let us learn how to install this LAMP stack on [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1158","post","type-post","status-publish","format-standard","category-general","entry"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Nikitha S.","author_link":"https:\/\/blog.hostingspell.com\/author\/nikitha\/"},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"single-featured-image":false,"blog-featured-image":false,"home-featured":false,"ab-block-post-grid-landscape":false,"ab-block-post-grid-square":false,"author-pro-image":false,"gb-block-post-grid-landscape":false,"gb-block-post-grid-square":false},"uagb_author_info":{"display_name":"Nikitha S.","author_link":"https:\/\/blog.hostingspell.com\/author\/nikitha\/"},"uagb_comment_info":0,"uagb_excerpt":"If you have reached this page then you most likely know about a LAMP stack. LAMP stack is a group of basic applications that most websites running on a Linux server are served. LAMP stands for Linux, Apache, MySQL\/ MariaDB and PHP. With this article, let us learn how to install this LAMP stack on&hellip;","_links":{"self":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts\/1158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/comments?post=1158"}],"version-history":[{"count":0,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/posts\/1158\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/media?parent=1158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/categories?post=1158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hostingspell.com\/wp-json\/wp\/v2\/tags?post=1158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}