Installing nginx on Ubuntu is straightforward — just run apt-get install nginx.
However, today I set up CentOS 6.2 and found that yum install nginx doesn’t work directly. You need to configure the repository first. Here’s the complete installation process, which is also quite simple:
1. For CentOS 6, first run:
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
2. Check the nginx info in yum
# yum info nginx
Loaded plugins: fastestmirror
……
3. Install and start nginx
[root@server ~]# yum install nginx
[root@server ~]# service nginx start
Starting nginx: [ OK ]
4. Then open your browser and enter http://192.168.0.101/ to test. If you see
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
Congratulations, you’ve done it!
If you cannot connect to nginx, there could be many reasons, but first check:
1. Whether the nginx service is actually running;
2. Whether the Linux server firewall is enabled
If you’re unable to install, refer to the following:
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
[root@localhost ~]# yum list | grep nginx
yum -y install nginx
[root@localhost ~]# find / -name *nginx*/etc/nginx/nginx.conf[root@localhost ~]# whereis nginxnginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
[root@localhost ~]# service nginx start