Home  >  Article  >  Backend Development  >  Install Nginx on CentOS

Install Nginx on CentOS

WBOY
WBOYOriginal
2016-08-08 09:20:06998browse

Redirected to: http://my.oschina.net/VincentJiang/blog/224993

CENTOS 6.5 Configure YUM to install NGINX

The first step is in <spanmicrosoft yahei font-size:14px>/etc/yum.repos.d/</spanmicrosoft> Create a source configuration file <spanmicrosoft yahei font-size:14px>nginx.repo</spanmicrosoft> in the directory:

cd /etc/yum.repos.d/
 
vim nginx.repo
Fill in the following content:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

(Note: ngin The x.repo file is for When using yum to install nginx, you can download the corresponding system version. I am using CentOS, so write /centos/) in the baseurl

and save it, a <spanmicrosoft yahei font-size:14px> will be generated. /etc/yum.repos.d/nginx.repo</spanmicrosoft> file. Just execute the following command to automatically install Nginx:

yum install nginx -y

After the installation is complete, you can start Nginx directly:

/etc/init.d/nginx start

Now Nginx has After it is started, you can see the Nginx welcome page by directly accessing the server. If you still cannot access it, you need to configure the Linux firewall.

iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
 
service iptables save
 
service iptables restart

Nginx command and configuration file location:


/etc/init.d/nginx start # 启动Nginx服务
 
/etc/init.d/nginx stop # 停止Nginx服务
 
/etc/nginx/nginx.conf # Nginx配置文件位置

At this point, Nginx has been fully configured and installed.

The above introduces the installation of Nginx on CentOS, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP database operationsNext article:PHP database operations