{"id":4536,"date":"2015-04-12T14:38:36","date_gmt":"2015-04-12T06:38:36","guid":{"rendered":"http:\/\/rmohan.com\/?p=4536"},"modified":"2015-04-12T14:42:36","modified_gmt":"2015-04-12T06:42:36","slug":"lamp-server-on-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4536","title":{"rendered":"LAMP server on centos 7"},"content":{"rendered":"<p><strong>LAMP server on centos 7<\/strong><\/p>\n<p>LAMP is a group of open source softwares installed together to build a webserver. LAMP refers to Linux (Operating system), Apache (Web service), MySQL\/MariaDB (Database) , PHP (Programming language).<br \/>\nThis guide helps you to install LAMP server on centos 7.<br \/>\nBefore starting installation, you need to setup Static IP and hostname .<br \/>\nYou can also refer this guide &#8211; Setup network on centos 7 to setup static ip and hostname.<br \/>\nInstall LAMP server on centos 7.<br \/>\n1. Apache installation.<br \/>\n2. Mysql installation.<br \/>\n3. PHP installation.<br \/>\n4. Testing all together.<br \/>\nlet\u2019s start<\/p>\n<p>Apache installation<br \/>\nStep 1 \u00bb Update the repositories.<br \/>\n[root@clusterserver1 ~]# yum check-update<\/p>\n<p>[root@clusterserver1 ~]# yum update<\/p>\n<p>[root@clusterserver1 ~]# yum install httpd<br \/>\nLoaded plugins: fastestmirror<br \/>\nLoading mirror speeds from cached hostfile<br \/>\n* base: mirror.vodien.com<br \/>\n* epel: mirrors.vinahost.vn<br \/>\n* extras: mirror.vodien.com<br \/>\n* updates: mirror.vodien.com<br \/>\nPackage httpd-2.4.6-31.el7.centos.x86_64 already installed and latest version<br \/>\nNothing to do<br \/>\n[root@clusterserver1 ~]#<\/p>\n<p>Apache installation<br \/>\nStep 1 \u00bb Update the repositories.<\/p>\n<p>[root@clusterserver1 ~]# systemctl start httpd.service<br \/>\n[root@clusterserver1 ~]# systemctl star^Chttpd.service<br \/>\n[root@clusterserver1 ~]# systemctl enable httpd.service<br \/>\n[root@clusterserver1 ~]# systemctl status httpd.service<br \/>\nhttpd.service &#8211; The Apache HTTP Server<br \/>\nLoaded: loaded (\/usr\/lib\/systemd\/system\/httpd.service; enabled)<br \/>\nActive: active (running) since Sun 2015-04-12 03:30:50 SGT; 6min ago<br \/>\nMain PID: 25200 (httpd)<br \/>\nStatus: &#8220;Total requests: 0; Current requests\/sec: 0; Current traffic:\u00a0\u00a0 0 B\/sec&#8221;<br \/>\nCGroup: \/system.slice\/httpd.service<br \/>\n??25200 \/usr\/sbin\/httpd -DFOREGROUND<br \/>\n??25201 \/usr\/sbin\/httpd -DFOREGROUND<br \/>\n??25202 \/usr\/sbin\/httpd -DFOREGROUND<br \/>\n??25203 \/usr\/sbin\/httpd -DFOREGROUND<br \/>\n??25204 \/usr\/sbin\/httpd -DFOREGROUND<br \/>\n??25205 \/usr\/sbin\/httpd -DFOREGROUND<\/p>\n<p>Apr 12 03:30:50 clusterserver1 httpd[25200]: AH00558: httpd: Could not reliably determine the server&#8217;s fully qualified domain &#8230;essage<br \/>\nApr 12 03:30:50 clusterserver1 systemd[1]: Started The Apache HTTP Server.<br \/>\nApr 12 03:37:16 clusterserver1 systemd[1]: Started The Apache HTTP Server.<br \/>\nHint: Some lines were ellipsized, use -l to show in full.<\/p>\n<p>By default, Apache will listen on port 80. you need to exclude from firewall.<br \/>\nyou can simply exclude http service from firewall.<\/p>\n<p>firewall-cmd &#8211;permanent &#8211;add-service http<br \/>\nor you can exclude using port number. Below command will be useful for ports other than 80<\/p>\n<p>firewall-cmd &#8211;permanent &#8211;add-port=8080\/tcp<\/p>\n<p>Step 5 \u00bb Now restart firewall service.<br \/>\nsystemctl restart firewalld.service<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4538\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache.png\" alt=\"apache\" width=\"599\" height=\"181\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache.png 599w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache-300x91.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache-150x45.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache-400x121.png 400w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>MySQL installation.<\/p>\n<p>Start installing MariaDB, MySQL drop-in replacement.<br \/>\n[root@clusterserver1 ~]# yum install mariadb-server mariadb<br \/>\n[root@clusterserver1 ~]# systemctl start mariadb<br \/>\n[root@clusterserver1 ~]#<br \/>\n[root@clusterserver1 ~]# mysql_secure_installation<br \/>\n\/usr\/bin\/mysql_secure_installation: line 379: find_mysql_client: command not found<\/p>\n<p>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB<br \/>\nSERVERS IN PRODUCTION USE!\u00a0 PLEASE READ EACH STEP CAREFULLY!<\/p>\n<p>In order to log into MariaDB to secure it, we&#8217;ll need the current<br \/>\npassword for the root user.\u00a0 If you&#8217;ve just installed MariaDB, and<br \/>\nyou haven&#8217;t set the root password yet, the password will be blank,<br \/>\nso you should just press enter here.<\/p>\n<p>Enter current password for root (enter for none):<br \/>\nERROR 1045 (28000): Access denied for user &#8216;root&#8217;@&#8217;localhost&#8217; (using password: YES)<br \/>\nEnter current password for root (enter for none):<br \/>\nOK, successfully used password, moving on&#8230;<\/p>\n<p>Setting the root password ensures that nobody can log into the MariaDB<br \/>\nroot user without the proper authorisation.<\/p>\n<p>Set root password? [Y\/n] Y<br \/>\nNew password:<br \/>\nRe-enter new password:<br \/>\nPassword updated successfully!<br \/>\nReloading privilege tables..<br \/>\n&#8230; Success!<\/p>\n<p>By default, a MariaDB installation has an anonymous user, allowing anyone<br \/>\nto log into MariaDB without having to have a user account created for<br \/>\nthem.\u00a0 This is intended only for testing, and to make the installation<br \/>\ngo a bit smoother.\u00a0 You should remove them before moving into a<br \/>\nproduction environment.<\/p>\n<p>Remove anonymous users? [Y\/n] Y<br \/>\n&#8230; Success!<\/p>\n<p>Normally, root should only be allowed to connect from &#8216;localhost&#8217;.\u00a0 This<br \/>\nensures that someone cannot guess at the root password from the network.<\/p>\n<p>Disallow root login remotely? [Y\/n] n<br \/>\n&#8230; skipping.<\/p>\n<p>By default, MariaDB comes with a database named &#8216;test&#8217; that anyone can<br \/>\naccess.\u00a0 This is also intended only for testing, and should be removed<br \/>\nbefore moving into a production environment.<\/p>\n<p>Remove test database and access to it? [Y\/n] Y<br \/>\n&#8211; Dropping test database&#8230;<br \/>\n&#8230; Success!<br \/>\n&#8211; Removing privileges on test database&#8230;<br \/>\n&#8230; Success!<\/p>\n<p>Reloading the privilege tables will ensure that all changes made so far<br \/>\nwill take effect immediately.<\/p>\n<p>Reload privilege tables now? [Y\/n] y<br \/>\n&#8230; Success!<\/p>\n<p>Cleaning up&#8230;<\/p>\n<p>All done!\u00a0 If you&#8217;ve completed all of the above steps, your MariaDB<br \/>\ninstallation should now be secure.<\/p>\n<p>Thanks for using MariaDB!<\/p>\n<p>PHP installation.<br \/>\nInstall PHP and other recommended packages.<br \/>\nyum install php php-mysql<\/p>\n<p>Additional packages are required if you would like to install phpmyadmin .<\/p>\n<p>yum install php-gd php-pear php-mbstring php-pgsql<\/p>\n<p>Now restart apache service<\/p>\n<p>systemctl restart httpd.service<\/p>\n<p>&nbsp;<\/p>\n<p>[root@clusterserver1 html]# cat phpinfo.php<br \/>\n&lt;?php phpinfo(); ?&gt;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4540\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache2.jpg\" alt=\"apache2\" width=\"1875\" height=\"729\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2.jpg 1875w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2-300x117.jpg 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2-1024x398.jpg 1024w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2-150x58.jpg 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2-400x156.jpg 400w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache2-900x350.jpg 900w\" sizes=\"(max-width: 1875px) 100vw, 1875px\" \/><\/a><\/p>\n<p>[root@clusterserver1 html]# cat dbtest.php<br \/>\n&lt;?php<br \/>\n$con = mysql_connect(&#8220;localhost&#8221;,&#8221;root&#8221;,&#8221;test123&#8243;);<br \/>\nif (!$con)<br \/>\n{<br \/>\ndie(&#8216;Could not connect: &#8216; . mysql_error());<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\necho &#8220;Congrats! connection established successfully&#8221;;<br \/>\n}<br \/>\nmysql_close($con);<br \/>\n?&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4541\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2015\/04\/apache3.jpg\" alt=\"apache3\" width=\"588\" height=\"167\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache3.jpg 588w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache3-300x85.jpg 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache3-150x43.jpg 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2015\/04\/apache3-400x114.jpg 400w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LAMP server on centos 7<\/p>\n<p>LAMP is a group of open source softwares installed together to build a webserver. LAMP refers to Linux (Operating system), Apache (Web service), MySQL\/MariaDB (Database) , PHP (Programming language). This guide helps you to install LAMP server on centos 7. Before starting installation, you need to setup Static IP and [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4536"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4536"}],"version-history":[{"count":5,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4536\/revisions"}],"predecessor-version":[{"id":4544,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4536\/revisions\/4544"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}