{"id":142,"date":"2009-05-24T01:33:16","date_gmt":"2009-05-23T23:33:16","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=142"},"modified":"2009-05-24T01:33:16","modified_gmt":"2009-05-23T23:33:16","slug":"quick-n-easy-lamp-server-for-centosrhel","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2009\/05\/24\/quick-n-easy-lamp-server-for-centosrhel\/","title":{"rendered":"Quick &#8216;n&#8217; Easy LAMP Server For CentOS\/RHEL"},"content":{"rendered":"<p>Install Apache<\/p>\n<p>Apache is the most popular Web HTTP server for a Linux servers.<\/p>\n<p><code>yum install httpd httpd-devel<\/code><\/p>\n<p>We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side. \/etc\/httpd\/conf\/httpd.conf &#8211; Apache configuration file location.<\/p>\n<p><code>\/etc\/init.d\/httpd start<\/code><\/p>\n<p>Install MySQL Database Server<\/p>\n<p>MySQL is a widely used open source database server on most Linux servers and can very well integrate to PHP and Apache server on CentOS\/RHEL.<\/p>\n<p><code>yum install mysql mysql-server mysql-devel<\/code><\/p>\n<p>If you attempt to type mysql in command prompt, you will be getting this nasty error.<\/p>\n<p><code>ERROR 2002 (HY000): Can\u2019t connect to local MySQL server through socket \u2018\/var\/lib\/mysql\/mysql.sock\u2019<\/code><\/p>\n<p>This is because you are not running the mysqld daemon before launching the mysql client. The file \/var\/lib\/mysql\/mysql.sock will be automatically created upon running the first instance of mysql.<\/p>\n<p>To fix:<\/p>\n<p>First start the mysql daemon, then type mysql:<\/p>\n<p><code>\/etc\/init.d\/mysqld start<br \/>\nmysql<\/code><\/p>\n<p>Changing MySQL Root Password<\/p>\n<p>By default the root password is empty for the mysql database. It is a good idea to change the mysql root password to a new one from a security point of view.<\/p>\n<p><code>mysql> USE mysql;<br \/>\nmysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';<br \/>\nmysql> FLUSH PRIVILEGES;<br \/>\n<\/code><br \/>\nOnce done, check by logging in:<\/p>\n<p><code>mysql -u root -p<br \/>\nEnter Password: <your new password><\/code><\/p>\n<p>To Create A New MySQL User<\/p>\n<p>To create a new mysql user &#8216;guest&#8217; with &#8216;all privileges&#8217; on the database &#8216;demo&#8217;:<\/p>\n<p><code>mysql > create database demo<br \/>\nmysql >GRANT ALL PRIVILEGES ON demo.* TO 'guest'@'localhost' IDENTIFIED BY 'guest' WITH GRANT OPTION;<br \/>\nmysql> UPDATE user SET Password=PASSWORD('guest') WHERE user='guest';<\/code><\/p>\n<p>That&#8217;s it! MySQL is ready! Don&#8217;t forget to remember the root password as we might be using it with phpmyadmin.<\/p>\n<p>Install PHP5 Scripting Language<\/p>\n<p>Installing PHP5 with the necessary modules is so easy and can be configured for both the Apache and mysql environment.<\/p>\n<p><code>yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml<\/code><\/p>\n<p>Don&#8217;t forget to install php-gd (gd library). It is very important if we plan to run captcha scripts on our server and so as other which are dependent on mysql and other functions.<\/p>\n<p>Restart Apache to load php.<\/p>\n<p><code>\/etc\/init.d\/httpd restart<\/code><\/p>\n<p>To Test If PHP Is Working Or Not:<\/p>\n<p>Create a file named \/var\/www\/html\/test.php with the following phpinfo() function inside php quotes.<\/p>\n<p><code><?php\n  phpinfo();\n  ?><br \/>\n<\/code><br \/>\nThen point your browser to http:\/\/ip.address\/test.php.<\/p>\n<p>That&#8217;s it! You should see a php configuration file displaying all kind of paths and installed modules.<\/p>\n<p>Closely observe the installed configuration on your server.<\/p>\n<p>* PHP Paths (php.ini path)<br \/>\n* Apache paths and Loaded Modules (mod_security, mod_evasive if installed_<br \/>\n* PHP GD Library<br \/>\n* MySQL paths and other information<\/p>\n<p>Install phpMyAdmin<\/p>\n<p>phpMyAdmin is a free web based MySQL database Administration Tool. Without phpMyAdmin it is almost impossible to mysql db operations in the command line. phpMyAdmin has become so convenient and it is absolutely sought by most webmasters to be present along with the mysql server.<\/p>\n<p><code>yum install phpmyadmin<\/code><\/p>\n<p>Point your browser to: http:\/\/ip.address\/phpmyadmin.<\/p>\n<p>Common Errors<\/p>\n<p>You might encounter the following errors while configuring phpmyadmin.<\/p>\n<p><code>Forbidden<br \/>\nYou don't have permission to access \/phpmyadmin\/ on this server.<\/code><\/p>\n<p>To fix:<\/p>\n<p>Edit the \/etc\/httpd\/conf.d\/phpmyadmin.conf and uncomment the line deny from all.<\/p>\n<p><code>nano \/etc\/httpd\/conf.d\/phpmyadmin.conf<\/code><\/p>\n<p><code><Directory \"\/usr\/share\/phpmyadmin\"><br \/>\n  Order Deny,Allow<br \/>\n  # Deny from all<br \/>\n  Allow from 127.0.0.1<br \/>\n  <\/Directory><br \/>\n<\/code><br \/>\nError<br \/>\nThe configuration file now needs a secret passphrase (blowfish_secret)<\/p>\n<p>To fix:<\/p>\n<p><code>nano \/usr\/share\/phpmyadmin\/conf.inc.php<\/code><\/p>\n<p>Look for a line and enter any password. Just dont leave it empty!<\/p>\n<p><code>$cfg['blowfish_secret'] = 'mydemopass'; \/* YOU MUST FILL IN THIS FOR COOKIE AUTH! *\/<\/code><\/p>\n<p>It worked for me using the above methods!<br \/>\nLog into the phpmyadmin with the mysql root password we changed while installing the mysql database.<\/p>\n<p>Install Webmin<\/p>\n<p>Webmin a free server hosting control panel  for Linux. It is a web based hosting administration tool and can be handy to tweak settings in your server if you are a beginner to Linux! You can download webmin here. Since webmin cannot be installed using yum, we can download an RPM package and install it on our server.<\/p>\n<p><code>wget <webmin rpm path><br \/>\nrpm - i webmin-1.410-1.noarch.rpm<\/code><\/p>\n<p>That should be a pretty easy installation! Remember webmin uses port 10000 and should not be blocked by your firewall.<\/p>\n<p>Point your browser to: http:\/\/ip.address:10000<\/p>\n<p>You should see a webmin login. But we don&#8217;t know the login and password yet! To set up the webmin password run the script below&#8230;<\/p>\n<p><code>\/usr\/libexec\/webmin\/changepass.pl \/etc\/webmin admin <newpasswd><\/code><\/p>\n<p>Log in with the admin username and new webmin password!<br \/>\nTo uninstall webmin, just run:<\/p>\n<p><code>\/etc\/webmin\/uninstall.sh<\/code><\/p>\n<p>Final Steps<\/p>\n<p>We want the Apache and mysql to be loaded at every boot so we switch them on using chkconfig:<\/p>\n<p><code>chkconfig httpd on<br \/>\nchkconfig mysqld on<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install Apache Apache is the most popular Web HTTP server for a Linux servers. yum install httpd httpd-devel We might need the httpd-devel libraries to compile and install other modules from the sources, just to be on the safer side. \/etc\/httpd\/conf\/httpd.conf &#8211; Apache configuration file location. \/etc\/init.d\/httpd start Install MySQL Database Server MySQL is a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-142","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":1,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":143,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/142\/revisions\/143"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}