{"id":432,"date":"2016-01-24T06:29:07","date_gmt":"2016-01-24T01:29:07","guid":{"rendered":"http:\/\/www.blueangel.host\/blog\/?p=432"},"modified":"2024-12-08T18:54:51","modified_gmt":"2024-12-08T13:54:51","slug":"how-to-install-nginx-on-centos-6-7-64bit","status":"publish","type":"post","link":"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/","title":{"rendered":"How to install Nginx on Centos 6.7 64bit"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"69\" src=\"http:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/NGINX-blueangelhost-300x69.png\" alt=\"How to install Nginx\" class=\"wp-image-433\" srcset=\"https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/NGINX-blueangelhost-300x69.png 300w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/NGINX-blueangelhost.png 626w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Nginx_Introduction\" >Nginx Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Installing_EPEL_in_CentOS_67_for_LEMP\" >Installing EPEL in CentOS 6.7 for LEMP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Installing_and_Configuring_NGINX_in_CentOS_67_for_LEMP\" >Installing and Configuring NGINX in CentOS 6.7 for LEMP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Installing_and_Configuring_MySQL_on_CentOS_67_for_LEMP\" >Installing and Configuring MySQL on CentOS 6.7 for LEMP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.blueangel.host\/blog\/how-to-install-nginx-on-centos-6-7-64bit\/#Installing_and_Configuring_php-fpm_on_CentOS_67_for_LEMP\" >Installing and Configuring php-fpm on CentOS 6.7 for LEMP<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Nginx_Introduction\"><\/span>Nginx Introduction<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>It is a high performance web server that is responsible for handling the load of some of the largest and high traffic websites on the internet.<br \/>\nIn this Tutorial we will show you How to install LEMP on your CentOS 6.7 Server. LEMP is a software bundle that is made up of four parts (Linux, Nginx, MySQL, and PHP). In this Tutorial we will be using CentOS 6.7 which was released on August 7th, 2015, Nginx version 1.0.15, MySQL version 5.1.73 and php-fpm using PHP version 5.3.3.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>we will require a VPS or a Dedicated server with Centos 6.7 64bit. you can get one from <a href=\"https:\/\/www.blueangel.host\/offshore-ssd-vps.html\" target=\"_blank\" rel=\"noreferrer noopener\">here.<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installing_EPEL_in_CentOS_67_for_LEMP\"><\/span>Installing EPEL in CentOS 6.7 for LEMP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>First we will install the Fedora epel release to quickly install Nginx. Run the following command to install EPEL<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>yum install epel-release<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installing_and_Configuring_NGINX_in_CentOS_67_for_LEMP\"><\/span>Installing and Configuring NGINX in CentOS 6.7 for LEMP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install NGINX with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo yum install nginx<\/p>\n<\/blockquote>\n\n\n\n<p>Start the NGINX service with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo \/etc\/init.d\/nginx start<\/p>\n<\/blockquote>\n\n\n\n<p>Configure NGINX to start when the system is rebooted:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo chkconfig nginx on<\/p>\n<\/blockquote>\n\n\n\n<p>You will now have NGINX installed on your server. This can be verified by typing in the following with your IP ADDRESS on your browser. Also, all configuration files are provided on the page.<\/p>\n\n\n\n<p>We can now verify Apache is working by opening your browser and entering the URL <strong><em>http:\/\/your-server&#8217;s-address<\/em><\/strong>. you should get a blue Nginx test page similar to the image below.<\/p>\n\n\n\n<p>Note: If you do not know your IP address, run the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo ip addr show eth0<\/p>\n<\/blockquote>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"751\" height=\"65\" src=\"http:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/anet-install-lemp-centos-7-06.png\" alt=\"anet-install-lemp-centos-7-06\" class=\"wp-image-439\" srcset=\"https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/anet-install-lemp-centos-7-06.png 751w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/anet-install-lemp-centos-7-06-300x26.png 300w\" sizes=\"auto, (max-width: 751px) 100vw, 751px\" \/><\/figure>\n<\/div>\n\n\n<p><br \/>\nIn our example we would put http:\/\/192.168.100.10 into our browser\u2019s address bar.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installing_and_Configuring_MySQL_on_CentOS_67_for_LEMP\"><\/span><figure><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-444 size-full\" src=\"http:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1.jpg\" alt=\"Install-LEMP-on-CentOS6-1\" width=\"1457\" height=\"282\" srcset=\"https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1.jpg 1457w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1-300x58.jpg 300w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1-1024x198.jpg 1024w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1-768x149.jpg 768w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LEMP-on-CentOS6-1-1080x209.jpg 1080w\" sizes=\"auto, (max-width: 1457px) 100vw, 1457px\" \/><\/figure><br \/>\nInstalling and Configuring MySQL on CentOS 6.7 for LEMP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install MySQL with the following command to begin the install:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo yum install mysql-server<\/p>\n<\/blockquote>\n\n\n\n<p>Start the service with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo service mysqld start<\/p>\n<\/blockquote>\n\n\n\n<p>Set root MySQL password with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo \/usr\/bin\/mysql_secure_installation<\/p>\n<\/blockquote>\n\n\n\n<p>Note: You will be prompted with a series of questions. Just type Y for yes on all of them, see the screen shot below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"695\" src=\"http:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-1.jpg\" alt=\"Install-LAMP-on-CentOS6-1\" class=\"wp-image-445\" srcset=\"https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-1.jpg 766w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-1-300x272.jpg 300w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/figure>\n<\/div>\n\n\n<p><br \/>\nConfigure MySQL to start when the system is rebooted:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo chkconfig mysqld on<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installing_and_Configuring_php-fpm_on_CentOS_67_for_LEMP\"><\/span>Installing and Configuring php-fpm on CentOS 6.7 for LEMP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Install php-fpm with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo yum install php-fpm php-mysql<\/p>\n<\/blockquote>\n\n\n\n<p>Start the php-fpm service with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo service php-fpm restart<\/p>\n<\/blockquote>\n\n\n\n<p>Make sure php-fpm starts on boot with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo chkconfig php-fpm on<\/p>\n<\/blockquote>\n\n\n\n<p>Using your favorite editor, edit the file <strong><em>\/etc\/php-fpm.d\/www.con<\/em><\/strong> and change user and group from apache to nginx. It should look similar to the block below.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>; Unix user\/group of processes<br \/>\n; Note: The user is mandatory. If the group is not set, the default user&#8217;s group<br \/>\n; will be used.<br \/>\n; RPM: apache Choosed to be able to access some dir as httpd<br \/>\nuser = nginx<br \/>\n; RPM: Keep a group allowed to write in log dir.<br \/>\ngroup = nginx<\/p>\n<\/blockquote>\n\n\n\n<p>Now we need to make some changes to the Nginx configuration file so that php-fpm works correctly with Nginx. Using your favorite editor, edit the file <strong><em>\/etc\/nginx\/conf.d\/default.conf<\/em><\/strong> and carry out the following changes or copy the following block below into your conf file.<\/p>\n\n\n\n<p>1) Add the index.php to the index location<\/p>\n\n\n\n<p>2) Change the root location to \/usr\/share\/nginx\/html<\/p>\n\n\n\n<p>3) Uncomment the Pass PHP scripts to FastCGI section.<\/p>\n\n\n\n<p>4) Change the fastcgi_param SCRIPT_FILENAME to use <strong>\/usr\/share\/nginx\/html$fastcgi_script_name<\/strong><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>#<br \/>\n# The default server<br \/>\n#<br \/>\nserver {<br \/>\nlisten 80 default_server;<br \/>\nserver_name _;<br \/>\n#charset koi8-r;<br \/>\n#access_log logs\/host.access.log main;<br \/>\n# Load configuration files for the default server block.<br \/>\ninclude \/etc\/nginx\/default.d\/*.conf;<br \/>\nlocation \/ {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\nindex index.php index.html index.htm;<br \/>\n}<br \/>\nerror_page 404 \/404.html;<br \/>\nlocation = \/404.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<br \/>\n# redirect server error pages to the static page \/50x.html<br \/>\n#<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<br \/>\n# proxy the PHP scripts to Apache listening on 127.0.0.1:80<br \/>\n#<br \/>\n#location ~ \\.php$ {<br \/>\n# proxy_pass http:\/\/127.0.0.1;<br \/>\n#}<br \/>\n# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>\n#<br \/>\nlocation ~ \\.php$ {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\nfastcgi_pass 127.0.0.1:9000;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME \/usr\/share\/nginx\/html$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<br \/>\n# deny access to .htaccess files, if Apache&#8217;s document root<br \/>\n# concurs with nginx&#8217;s one<br \/>\n#<br \/>\n#location ~ \/\\.ht {<br \/>\n# deny all;<br \/>\n#}<br \/>\n}<\/p>\n<\/blockquote>\n\n\n\n<p>Create a test PHP file in the following directory with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo vi <tt>\/usr\/share\/nginx\/html\/info.php<\/tt><\/p>\n<\/blockquote>\n\n\n\n<p>Insert the following code in the space then save and exit:<\/p>\n\n\n\n<p>Restart apache so all the changes take effect:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo service nginx restart<\/p>\n<\/blockquote>\n\n\n\n<p>Test your page in your browser with the following hyperlink changed with yourIP address:<br \/>\nhttp:\/\/YOUR.IP.ADD.RESS\/info.php<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"862\" height=\"741\" src=\"http:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-3.jpg\" alt=\"Install-LAMP-on-CentOS6-3\" class=\"wp-image-446\" srcset=\"https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-3.jpg 862w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-3-300x258.jpg 300w, https:\/\/www.blueangel.host\/blog\/wp-content\/uploads\/2016\/01\/Install-LAMP-on-CentOS6-3-768x660.jpg 768w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>You should removed the info.php file as it could be used against you by an attacker. Delete it with the following command:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>sudo rm \/usr\/share\/nginx\/html\/info.php<\/p>\n<\/blockquote>\n\n\n\n<p>Congratulations! You have just installed LEMP on your CentOS 6.7 Server. Thank you for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx Introduction It is a high performance web server that is responsible for handling the load of some of the largest and high traffic websites on the internet. In this Tutorial we will show you How to install LEMP on your CentOS 6.7 Server. LEMP is a software bundle that is made up of four&#8230;<\/p>\n","protected":false},"author":2,"featured_media":433,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[1],"tags":[155,160,156,157,158,159],"class_list":["post-432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-centos","tag-how-tos","tag-lemp","tag-mysql","tag-nginx","tag-php"],"_links":{"self":[{"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/posts\/432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":10,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":1478,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions\/1478"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/media\/433"}],"wp:attachment":[{"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blueangel.host\/blog\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}