{"id":383,"date":"2013-10-29T09:56:56","date_gmt":"2013-10-29T09:56:56","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=383"},"modified":"2013-10-29T09:56:56","modified_gmt":"2013-10-29T09:56:56","slug":"install-linux-lighttpd-mysql-php5-llmp-stack-centos-6","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2013\/10\/29\/install-linux-lighttpd-mysql-php5-llmp-stack-centos-6\/","title":{"rendered":"How To Install Linux, Lighttpd, MySQL, and PHP5 (LLMP Stack) on Centos 6"},"content":{"rendered":"<h3>Introduction<\/h3>\n<hr \/>\n<p>Lighttpd is an open source web server originally written by Jan Kneschke as an alternative to Apache, it has a low memory footprint and numerous websites such as YouTube and Wikimedia run Lighttpd servers. MySQL is a popular database solution for use in web applications (such as WordPress) and is generally combined with a server side scripting language, PHP.<\/p>\n<p>This tutorial will show you the steps required to install Lighttpd, PHP and MySQL on CentOs 6 so that you can get up and running with your Server.<\/p>\n<h2>Step One &#8211; Prerequisites<\/h2>\n<hr \/>\n<p>Update your system:<\/p>\n<pre>sudo yum update<\/pre>\n<p>You will need to install wget, a package for retrieving files using HTTP, HTTPS and FTP:<\/p>\n<pre>sudo yum install wget<\/pre>\n<p>Notice that the command starts with &#8220;sudo&#8221;. This will allow you to run the instructions with root privileges.<\/p>\n<h2>Step Two &#8211; Installing MySQL<\/h2>\n<hr \/>\n<p>To install MySQL, login into your VPS and type:<\/p>\n<pre>sudo yum install mysql-server<\/pre>\n<p>Create a system start-up link for MySQL to enable the services to run at boot:<\/p>\n<pre>sudo chkconfig --levels 235 mysqld on<\/pre>\n<p>This might seem silly, but it is a good idea to verify that the MySQL server is running, otherwise you will come up with a MySQL ERROR 2002 (HY000) when executing the mysql_secure_installation command:<\/p>\n<pre>sudo service mysqld status<\/pre>\n<p>If the VPS is not running type:<\/p>\n<pre>sudo service mysqld start<\/pre>\n<p>Create a password for the MySQL user root and perform some initial configurations:<\/p>\n<pre>sudo mysql_secure_installation\nEnter current password for root (enter for none):_<\/pre>\n<p>Since a MySQL root password has not been configured we can just press ENTER and continue with the process of setting up MySQL:<\/p>\n<pre>Set root password? [Y\/n] y\nNew password: SQL.ROOT.PASSWORD.EXAMPLE\nRe-enter new password: SQL.ROOT.PASSWORD.EXAMPLE\nRemove anonymous users? [Y\/n] y\nDisallow root login remotely? [Y\/n] y\nRemove test database and access to it? [Y\/n] y\nReload privilege tables now? [Y\/n] y<\/pre>\n<h2>Step Three &#8211; Installing Lighttpd<\/h2>\n<hr \/>\n<p>Lighttpd and PHP-FPM are not supported from the official CentOS repositories, let&#8217;s go ahead and add the Remi RPM and the EPEL repositories to CentOS:<\/p>\n<pre>sudo rpm --import <a href=\"https:\/\/fedoraproject.org\/static\/0608B895.txt\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/fedoraproject.org\/<wbr><\/wbr>static\/0608B895.txt<\/a>\nsudo wget <a href=\"http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/dl.fedoraproject.org\/<wbr><\/wbr>pub\/epel\/6\/x86_64\/epel-<wbr><\/wbr>release-6-8.noarch.rpm<\/a>\nsudo rpm -ivh epel-release-6-8.noarch.rpm<\/pre>\n<p>Then run the following command to install Lighttpd:<\/p>\n<pre>sudo yum install lighttpd<\/pre>\n<p>Create a system start-up link for Lighttpd to enable the service to run at boot:<\/p>\n<pre>sudo chkconfig --levels 235 lighttpd on<\/pre>\n<p>Start the service and check that it is running:<\/p>\n<pre>sudo service lighttpd start\nsudo service lighttpd status<\/pre>\n<p>Open your browser and type your VPS&#8217; IP\u00a0<a href=\"http:\/\/123.456.789.10\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/123.456.789.10<\/a>, you can run the following command to reveal your VPS&#8217; IP address:<\/p>\n<pre>ifconfig<\/pre>\n<p>The Lighttpd welcome page should be displayed:<\/p>\n<p><img decoding=\"async\" title=\"Lighttpd Welcome Page\" alt=\"\" src=\"https:\/\/i.imgur.com\/Rkundsg.png\" \/><\/p>\n<h2>Typical Errors &#8211; Lighttpd Troubleshooting<\/h2>\n<hr \/>\n<p>ERROR 1: Lighttpd fails to start:\u00a0<i>&#8220;socket failed: Address family not supported by protocol&#8221;<\/i>\u00a0or<i>&#8220;please use server.use-ipv6 only for hostnames, not without server.bind&#8230;&#8221;<\/i>\u00a0, open Lighttpd.conf:<\/p>\n<pre>sudo nano \/etc\/lighttpd\/lighttpd.conf<\/pre>\n<p>And disable IPv6:<\/p>\n<pre>##\nserver.use-ipv6 = \"disable\"\n##<\/pre>\n<p>ERROR 2: Warning\u00a0<i>&#8220;can&#8217;t have more connections than fds\/2: 1024 1024&#8221;<\/i>, open Lighttpd.conf:<\/p>\n<pre>sudo nano \/etc\/lighttpd\/lighttpd.conf<\/pre>\n<p>Uncomment\u00a0<strong>#server.max-fds = 2048<\/strong>:<\/p>\n<pre>##\nserver.max-fds = 2048\n##<\/pre>\n<p>Restart Lighttpd:<\/p>\n<pre>sudo service lighttpd restart\nStopping lighttpd [OK]\nStarting lighttpd [OK]<\/pre>\n<h2>Step Four &#8211; Installing PHP<\/h2>\n<hr \/>\n<p>Install PHP5 (FPM):<\/p>\n<pre>sudo yum install php-fpm lighttpd-fastcgi<\/pre>\n<p>Open www.conf:<\/p>\n<pre>sudo nano \/etc\/php-fpm.d\/www.conf<\/pre>\n<p>Add lighttpd to the user and group:<\/p>\n<pre>; Unix user\/group of processes\n; Note: The user is mandatory. If the group is not set, the default user's group\n;       will be used.\nuser = lighttpd\n; RPM: Keep a group allowed to write in log dir.\ngroup = lighttpd<\/pre>\n<p>Create a system start-up link for PHP-FPM to enable the service to run at boot:<\/p>\n<pre>sudo chkconfig --levels 235 php-fpm on<\/pre>\n<p>Start the service and check that it is running:<\/p>\n<pre>sudo service php-fpm start\nsudo service php-fpm status<\/pre>\n<p>Once the installation is complete, we have to enable PHP5 in Lighttpd. Let&#8217;s find your php.ini file:<\/p>\n<pre>sudo nano \/etc\/php.ini<\/pre>\n<p>And uncomment the required line:<\/p>\n<pre>;\ncgi.fix_pathinfo=1\n;<\/pre>\n<p>Open fastcgi.conf:<\/p>\n<pre>sudo nano \/etc\/lighttpd\/modules.conf<\/pre>\n<p>And uncomment this line:<\/p>\n<pre>##\ninclude \"conf.d\/fastcgi.conf\"\n##<\/pre>\n<p>Open fastcgi.conf<\/p>\n<pre>sudo nano \/etc\/lighttpd\/conf.d\/fastcgi.<wbr><\/wbr>conf<\/pre>\n<p>and add the following lines:<\/p>\n<pre>## for the php-num-procs example it means you will get 17*5 = 85 php\n## processes. you always should need this high number for your very\n## busy sites. And if you have a lot of RAM. :)\n## ADD YOUR LINES HERE\nfastcgi.server += ( \".php\" =&gt;\n        ((\n                \"host\" =&gt; \"127.0.0.1\",\n                \"port\" =&gt; \"9000\",\n                \"broken-scriptfilename\" =&gt; \"enable\"\n        ))\n)\n## GOOD JOB\n#fastcgi.server = ( \".php\" =&gt;<\/pre>\n<p>Install MySQL PHP module:<\/p>\n<pre>sudo yum install php-mysql<\/pre>\n<p>Restart Lighttpd and PHP-FPM:<\/p>\n<pre>sudo service php-fpm restart\nsudo service lighttpd restart<\/pre>\n<h2>Step Six (Optional) &#8211; Testing PHP using info.php<\/h2>\n<hr \/>\n<p>Create info.php:<\/p>\n<pre>sudo nano \/var\/www\/lighttpd\/info.php<\/pre>\n<p>Add the following lines:<\/p>\n<pre>&lt;?php\nphpinfo();\n?&gt;<\/pre>\n<p>Open your browser and go to your server&#8217;s IP\u00a0<a href=\"http:\/\/123.456.789.10\/info.php\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/123.456.789.10\/info.php<\/a>\u00a0.We can see that PHP is working through FPM\/FastCGI:<\/p>\n<p><img decoding=\"async\" title=\"PHP Info Page\" alt=\"\" src=\"https:\/\/i.imgur.com\/aMRpmOu.png\" \/><\/p>\n<p>And that the MySQL module is listed, therefore working:<\/p>\n<p><img decoding=\"async\" title=\"MySQL PHP Module\" alt=\"\" src=\"https:\/\/i.imgur.com\/ZdVBGMo.png\" \/><\/p>\n<p>And that is all; congratulations!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Lighttpd is an open source web server originally written by Jan Kneschke as an alternative to Apache, it has a low memory footprint and numerous websites such as YouTube and Wikimedia run Lighttpd servers. MySQL is a popular database solution for use in web applications (such as WordPress) and is generally combined with a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60],"tags":[148,149,150,151],"class_list":["post-383","post","type-post","status-publish","format-standard","hentry","category-linux","tag-and-php5-llmp-stack-on-centos-6","tag-how-to-install-linux","tag-lighttpd","tag-mysql"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=383"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/383\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}