打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Armbian

1. 参考Centos7安装Nginx

centos7安装nginx并自启
虽然都是linux,但是安装的依赖包有点差别。

    1. 安装编译依赖包
    sudo apt install build-essential
    
    1. 安装PCRE库
    sudo apt-get install libpcre3 libpcre3-dev
    
    1. 安装zlib库
    sudo apt-get install zlib1g-dev
    
    1. 安装OpenSSL
    sudo apt-get install openssl libssl-dev
    
    1. 编译安装
    cd nginx-1.18.0/
    ./configure --prefix=/usr/local/nginx  --with-http_ssl_module
    make & make install
    

2. 设置Nginx自启

Ubuntu 16.10开始不再使用initd管理系统,改用systemd,包括用systemctl命令来替换了service和chkconfig的功能。
比如以前启动mysql服务用sudo service mysql start,现在用sudo systemctl start mysqld.service。
systemd 默认读取 /etc/systemd/system 下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件

  • 1.建立服务文件
    vim /lib/systemd/system/nginx.service
    
    1. 复制如下内容写入到nginx.service中
    [Unit]
    Description=nginx - high performance web server
    After=network.target remote-fs.target nss-lookup.target
    [Service]
    Type=forking
    WorkingDirectory=/usr/local/nginx
    ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s stop
    PrivateTmp=true
    [Install]
    WantedBy=multi-user.target
    
    1. 使文件生效
    systemctl daemon-reload
    
    1. 启动 nginx
    systemctl start nginx
    systemctl enable nginx
    systemctl status nginx
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CentOS7离线安装Nginx,包含gcc、g++环境
centos7.6设置(tomcat,nginx)开机自启动
实战记录在 Linux Ubuntu 20.04 安装VNC 远程桌面
Ubuntu 22.04安装、配置和删除MySQL 8
podman初试
CentOS 7 Nginx 控制脚本「更新」
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服