Normally I install Nginx on CentOS / RHEL via the EPEL repo, however I have recently discovered the Nginx project has it’s own repo available. Note this will install a much newer Nginx version than the one available in the EPEL repo, follow the steps below to install Nginx on CentOS / RHEL.
Create the file /etc/yum.repo.d/nginx.repo and populate it with the following text (depending on your distro / version number).
Next you can simply yum install the latest version of nginx using:
1
yum install nginx
NOTE if you are only running one website and your html files are at the default site location updating Nginx via yum will overwrite your website files with the default Nginx site files. I recommend you install your website at a different location to avoid this, you should also check out my tutorial on optimizing Nginx for high traffic websites (currently writing will link here once it’s complete).