Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。
1.添加yum源rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2.yum安装
yum install -y nginx
3.启动
systemctl start nginx.service
这样安装就完成了,可以直接访问服务器的域名或公网ip,出现如下页面,就算是成功了。
nginx -v
查看nginx进程和安装目录
ps -ef | grep nginx
检查配置文件
nginx -t
启动
systemctl start nginx.service
停止
systemctl stop nginx.service
重启
systemctl restart nginx.service
设置开机自启动
systemctl enable nginx.service
取消开机自启动
systemctl disable nginx.service
查看当前状态
systemctl status nginx.service
查看所有已启动的服务
systemctl list-units --type=service
5.部署静态网页
切换到默认配置文件目录
cd /etc/nginx/conf.d
新建一个conf文件
vi xxx.conf
写入如下内容
server {
listen 8082; #访问的端口
server_name localhost; #访问主机
location / {
root /home/business/xxx; #网页所在目录,默认访问index.html文件,可自定义目录。
}
}
重启nginx服务
systemctl restart nginx.service