Most of my times are spent messing with stuff. When it comes to development, I do a lot of my testing in VMware Workstation and VirtualBox visualization software. I have VMware 10 Workstation installed on my home computer and VirtualBox on my work computer.
I do a lot of testing before implementing new changes to my websites and other productions systems.
When you’re in the business of hosting your own website or blog, you probably will want to do the same. You may want to get your hands on VirtualBox software which is free, and start creating and using virtual machines for testing purposes.
That’s what I do and many webmasters probably do the same.
Now back to the topic. This post is going to show you how to install Nginx in CentOS 6/6.5. Most websites run Apache web server. It’s the most popular and most supported.
That’s why installing Apache in CentOS or other Linux operating systems is easy. Most of these systems make Apache packages available for installation by default.
To install Apache, all one has to do is run the commands below after installing CentOS.
yum -y install httpd
Now, when it comes to Nginx, it’s not that simple.
Nginx isn’t as popular as Apache and doesn’t have the support Apache has. So, to install Nginx in CentOS, you must first add its software repository before you can install it.
- Adding Nginx repository in CentOS
To add Nginx repository in CentOS, run the commands below.
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
The commands above download Nginx repository information and save it in /etc/yum.repos.d/ directory. This is the default location for software repositories in CentOS.
When the repository is added, all you have to do is run the commands below to install Nginx.
yum -y install nginx
Then start Nginx web server using the commands below.
service nginx start
Normally, you’ll want to run the commands below so that when your computer is restarted, Nginx will automatically start.
chkconfig nginx on
If you need to see what’s included in Nginx repository file, or if you want to manually create the repository file youself, here’s what in it. It is stored in /etc/yum.repos.d/nginx.conf
[nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1
Another issue most new webmasters run into after installing CentOS is that all everything is blocked by the firewall. In order for your website to be seen, you must open port 80 through the firewall.
To do that, run the commands below.
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
Finally save your changes and open your browser and browse to the host computer to test Nginx installation.
service iptables save
service iptables restart
Try accessing your site or host computer and you should see something like the page below.