CentOS rpm安装Nginx和配置

官方下载地址: http://nginx.org/en/download.html

介绍

Nginx(“engine x”)是一款由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。

rpm包安装

#安装nginx,rpm安装
#rpm安装nginx包
rpm -Uvh --force --nodeps nginx-1.16.1-1.el7.ngx.x86_64.rpm#查看启动状态
systemctl status nginx显示如下:
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)Active: active (running) since 五 2021-11-26 11:12:41 CST; 5 days agoDocs: http://nginx.org/en/docs/Process: 1379 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)Main PID: 1543 (nginx)Tasks: 5CGroup: /system.slice/nginx.service├─1543 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf├─1544 nginx: worker process├─1546 nginx: worker process├─1547 nginx: worker process└─1548 nginx: worker process11月 26 11:12:41 liang systemd[1]: Starting nginx - high performance web server...
11月 26 11:12:41 liang systemd[1]: Started nginx - high performance web server.#启动
systemctl start nginx#重启
systemctl restart nginx#开机自启动服务
systemctl enable nginx#查看开机启动状态 enabled:开启, disabled:关闭
systemctl is-enabled nginx

安装完后在 修改 /etc/nginx/conf.d/default.conf 配置文件,参考内容如下:

vim /etc/nginx/conf.d/default.conf

server {listen       80;server_name  localhost;#charset koi8-r;#access_log  /var/log/nginx/host.access.log  main;location /ui {alias   /data/dist;index  index.html index.htm;}location /file/ {root   /home/data/;index  index.html index.htm;}    # websocket配置wsslocation /liangws/ {proxy_pass http://192.168.0.19:8080/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header Remote_addr $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_read_timeout 600s;}location ~ /gat {proxy_set_header Host  $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://localhost:18080 ;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
}

注意:静态文件下载,需要依赖nginx,我们需要将这些文件放到 nginx配置文件中的 /home/data/aaa 对应的目录下。

启动服务配置

cat /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID[Install]
WantedBy=multi-user.target

CentOS rpm安装Nginx和配置相关推荐

  1. nginx linux 下载安装,Linux(CentOS)下载安装Nginx并配置

    一.查看yum的nginx信息[root@server ~]# yum info nginx 二.安装并启动nignx[root@server ~]# yum install nginx [root@ ...

  2. linux nginx rpm 安装配置,Centos下安装nginx rpm包

    1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...

  3. linux slf4j.rpm,Centos下安装nginx rpm包

    1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html wget http://nginx.org/packages/centos/6 ...

  4. 在CentOs 5.1中使用rpm安装NGINX+php+mysql(二)

    算是原创.转载请注明此地址,随着对NGINX认知的深入,此文会不定期更新或是修正. 以下兵分两路来说明:一是直接利用php-cgi的FastCGI运行方式:二是利用Lighttpd的spawn-fcg ...

  5. CentOS 7 安装 Nginx

    CentOS 7 安装 Nginx 1.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-d ...

  6. 在CentOS上安装nginx服务器

    一.环境描述 1. 虚拟机配置 CPU:单核 内存:2 GB 硬盘:120 GB IP:10.24.17.108 2. 操作系统 版本:CentOS 6.6 x86_64 安装方式:Minimal 3 ...

  7. docker安装nginx,配置nginx,并成功访问

    [Nginx那些事]系列 [Nginx那些事]nginx 安装及常用指令 [Nginx那些事]Nginx 配置文件说明 [Nginx那些事]nginx原理解析 [Nginx那些事]nginx配置实例( ...

  8. elasticsearch rpm安装及详细配置

    elasticsearch使用rpm安装及详细配置 下载elasticsearch的rpm包 安装elasticsearch 创建elasticsearch管理用户 设置文件和目录权限为elk 设置启 ...

  9. Windows安装nginx并配置端口转发

    Windows安装nginx并配置端口转发 1.场景 在VMware虚拟机中启动了几个Linux,采用的是NAT网络配置,所以另一个Windows访问无法进行ssh或者其它应用的访问 2.安装 2.1 ...

最新文章

  1. 王道考研 计算机网络笔记 第六章:应用层
  2. pytorch使用 torchvision 的 Transform 读取图片数据
  3. input placeholder样式
  4. extremeComponents(ec)源码分析
  5. android 恶意广告,CheckPoint:Android恶意广告软件SimBad被下载近1.5亿次
  6. List Set Map的区别
  7. 手机移动防卫盾安全需求分析文档
  8. c语言也能用模板方法模式?
  9. JavaWeb 项目时 启动一个线程
  10. 回溯算法 思路清晰,通俗易懂!!!!!!!
  11. Android 获取网络错误
  12. 拓端tecdat|R语言区间数据回归分析
  13. [裴礼文数学分析中的典型问题与方法习题参考解答]4.3.1
  14. golang程序员前景怎么样?Python、Java、go语言的优势互比
  15. 【庖丁解牛】成功解决nginx报错:bind() to 0.0.0.0:8090 failed (13: Permission denied)
  16. 【战网】如果直接使用国服战网客户端登录亚服
  17. java使用wkhtmltopdf将html转换成pdf
  18. CTS、CTS-V、GTS版本更新,及其注意事项
  19. AT89S51编辑和烧录软件过程
  20. 学习力是这个时代的终极竞争力

热门文章

  1. linux系统小主机,首款ARM“芯”迷你主机诞生:支持安卓/Linux
  2. Openwrt 搭建 PPTP 服务器
  3. linux环境docker搭建pptp服务器
  4. python批量化修改文件名字(带窗口,可调整设置)
  5. Dom4j 解析 XML
  6. dapper mysql 多参数查询_使用Dapper进行参数化查询
  7. 1114: 十六进制转换
  8. android web hook,webhook
  9. 老家养牛比你在外面漂着舒服多了?
  10. iOS提交审核那些坑