{"id":2749,"date":"2012-05-11T14:48:55","date_gmt":"2012-05-11T06:48:55","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2749"},"modified":"2023-04-28T09:49:20","modified_gmt":"2023-04-28T09:49:20","slug":"how-to-install-and-configure-nginx-web-server-on-centos-6-2","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-configure-nginx-web-server-on-centos-6-2\/","title":{"rendered":"How to Install and Configure Nginx Web Server on CentOS 6.2"},"content":{"rendered":"<p>Nginx or &#8220;engine x&#8221; is a free, open-source HTTP server and one of the alternative to Apache http server. It&#8217;s a high performance edge web server with the lowest memory footprint and the key features to build modern and efficient web infrastructure. In this post, i will guide you through the basic steps to install and configure Nginx web server on linux CentOS 6.2 server.<\/p>\n<p>To add nginx yum repository, create a file named \/etc\/yum.repos.d\/nginx.repo.<\/p>\n<pre>\n[root@centos62 ~]# vi \/etc\/yum.repos.d\/nginx.repo\n<\/pre>\n<p>Paste one of the configurations below: <\/p>\n<pre>\n[nginx]\nname=nginx repo\nbaseurl=http:\/\/nginx.org\/packages\/centos\/$releasever\/$basearch\/\ngpgcheck=0\nenabled=1\n<\/pre>\n<p>Install nginx using yum command :<\/p>\n<pre>\n[root@centos62 ~]# yum install nginx -y\nLoaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: centos.ipserverone.com\n * epel: ftp.yz.yamagata-u.ac.jp\n * extras: centos.ipserverone.com\n * rpmforge: apt.sw.be\n * updates: centos.ipserverone.com\nnginx                                                                        | 1.3 kB     00:00\nnginx\/primary                                                                | 3.0 kB     00:00\nnginx                                                                                         17\/17\nSetting up Install Process\nResolving Dependencies\n--> Running transaction check\n---> Package nginx.i686 0:1.0.12-1.el6 will be updated\n---> Package nginx.i386 0:1.0.14-1.el6.ngx will be an update\n--> Finished Dependency Resolution\n\nDependencies Resolved\n\n====================================================================================================\n Package             Arch               Version                           Repository           Size\n====================================================================================================\nUpdating:\n nginx               i386               1.0.14-1.el6.ngx                  nginx               294 k\n\nTransaction Summary\n====================================================================================================\nUpgrade       1 Package(s)\n\nTotal download size: 294 k\nDownloading Packages:\nnginx-1.0.14-1.el6.ngx.i386.rpm                                              | 294 kB     00:43\nRunning rpm_check_debug\nRunning Transaction Test\nTransaction Test Succeeded\nRunning Transaction\n  Updating   : nginx-1.0.14-1.el6.ngx.i386                                                      1\/2\n  Cleanup    : nginx-1.0.12-1.el6.i686                                                          2\/2\n\nUpdated:\n  nginx.i386 0:1.0.14-1.el6.ngx\n\nComplete!\n<\/pre>\n<p>Modify default website config file :<\/p>\n<pre>\n[root@centos62 ~]# vi \/etc\/nginx\/conf.d\/default.conf\n<\/pre>\n<p>Original<\/p>\n<pre>\n location \/ {\n        root   \/usr\/share\/nginx\/html;\n        index  index.html index.htm;\n<\/pre>\n<p>Edit as below :<\/p>\n<pre>\n location \/ {\n        #root   \/usr\/share\/nginx\/html;\n        root   \/var\/www\/html\/nginxweb;\n        index  index.html index.htm;\n<\/pre>\n<p>Create index.html :<\/p>\n<pre>\n[root@centos62 ~]# vi \/var\/www\/html\/nginxweb\/index.html\n<\/pre>\n<p>Add this html code:<\/p>\n<pre>\n&lt;html&gt;\n&lt;body&gt;\n&lt;div style=&quot;width: 100%; font-size: 40px; font-weight: bold; text-align: center;&quot;&gt;\nTest Page for nginx web server\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>Start nginx web server :<\/p>\n<pre>\n[root@centos62 ~]# service nginx start\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Nginx or &#8220;engine x&#8221; is a free, open-source HTTP server and one of the alternative to Apache http server. It&#8217;s a high performance edge web server with the lowest memory&#8230;<\/p>\n","protected":false},"author":6,"featured_media":2750,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1014],"tags":[1253,1536,1546,1605,1914],"class_list":["post-2749","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-centos-6-2","tag-linux","tag-linux-utilities","tag-nginx","tag-web-server"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2749"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2749\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/2750"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}