软件安装:Linux安装Nginx

软件安装:Linux如何安装软件,程序。

源码安装 类似于.exe 源码包就是一堆源代码程序组成的。

linux tar.gz 这个就是源码包

源码包--------二进制包,源码包里面的代码经过编译之后形成的包。

优点:1、开源,可以二次修改,可以做二次开发,可以自由选择需要的功能。

​ 2、编译安装,与系统的适配性更高,更加稳定,卸载比较方便(删除即可)。

缺点:1、安装步骤多,容易出错

​ 2、编译的时间长

​ 3、一旦报错,新手很难解决

安装步骤: 1、源码包放到系统中

-rw-r--r--. 1 root root 1073322 5月  22 09:31 nginx-1.22.0.tar.gz
[root@localhost opt]# systemctl stop firewalld.service   关闭防火墙
[root@localhost opt]# setenforce 0

​ 2、安装编译过程中需要的依赖环境

yum -y install gcc pcre-devel openssl-devel zlib-devel openssl  openssl-devel

​ 3、创建nginx程序运行需要的用户和组

[root@localhost opt]# useradd -M -s /bin/nologin nginx    创建用户

​ 4、编译安装nginx

​ (1)解压

[root@localhost opt]# tar -xf nginx-1.22.0.tar.gz 

​ (2) 开始配置,配置程序安装路径,基于程序需要的相关组件。

[root@localhost nginx-1.22.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
       安装到 /usr/local/nginx目录下

​ (3)编译和安装 mack 编译 mack install 安装

[root@localhost nginx-1.22.0]# make && make install      编译并且安装

​ 5、后续配置,设置权限和系统管理配置。

(1) 权限配置(修改用户组和所属组)

[root@localhost local]# chown -R nginx.nginx nginx/  

(2)做一个软连接,让系统能够识别nginx的指令

[root@localhost ~]# ln -s /usr/local/nginx/sbin/nginx  /usr/bin/   设置软链接
[root@localhost ~]# nginx -t    查看配置状态、是否成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

(3)设置系统控制,系统能对nginx这个软件的运行状态进行控制

vim  /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
#表示支持dns解析以及该软件依赖于网络。
Wants=network-online.target
#先启动网络服务,才能启动nginx
[Service]
Type=forking
PIDFile=/usr/local/nginx/run/nginx.pid
#注意文件位置,如果不对 启动不了
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 
#注意启动文件位置
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
#支持多用户模式
:wq

(4)创建目录,修改nginx的配置文件

[root@localhost nginx]# mkdir /usr/local/nginx/run
[root@localhost nginx]# mkdir /usr/local/nginx/run
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;   修改位置    /usr/local/nginx/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
[root@localhost conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost /]# systemctl  daemon-reload     重新读取
[root@localhost /]# systemctl  restart nginx     启动ngin

rpm安装 基于安装包安装 .rpm

yum 安装方式就是rpm升级版

源码安装的升级版本

rpm 的安装解决了源码安装的繁琐,基本实现了一键安装,没有解决包一包之间的依赖关系。

rpm

-i 安装过程中的详细信息

-v 显示安装的过程中的详细信息

-h 在安装过程中已“#” 显示安装

rpm -ivh 安装包

rpm -q 软件名 (查询系统已经安装该软件)

httpd-2.4.6-88.el7.centos.x86 64

httpd :软件名称 apache web 软件

2.4.6 软件版本

88:更新迭代88次

x86_64: 64为的x86的CPU

  • 31
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码要你命

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值