首页 > 系统相关 >Nginx开机自启配置

Nginx开机自启配置

时间:2023-10-16 09:01:21浏览次数:34  
标签:sbin service nginx Nginx 自启 usr 开机 local

Nginx开机自启配置

Nginx1.13

安装位置 /usr/local/nginx
监听端口 80
配置文件地址 /usr/local/nginx/conf/

开机自启动

切换到/lib/systemd/system/目录,创建nginx.service文件vim nginx.service
# cd /lib/systemd/system/

# vim nginx.service

如下内容

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target

[Service]
Type=forking
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
退出并保存文件,执行systemctl enable nginx.service使nginx开机启动
# systemctl enable nginx.service

相关命令

权限问题
https://blog.csdn.net/qq_43445867/article/details/131588104
#切换到nginx目录
cd /usr/local/nginx/conf/
# 切换到sbin
cd /usr/local/nginx/sbin && ./nginx -s reload

标签:sbin,service,nginx,Nginx,自启,usr,开机,local
From: https://www.cnblogs.com/SunAlbert/p/17766608.html

相关文章

  • Redis安装及开机自启
    Redis6.2安装位置/data/redis访问端口6379配置文件地址/data/redis/bin/makePREFIX=/data/redisinstallcpredis.conf/data/redis/bin/cd/data/redis/bin/./redis-server/data/redis/bin/redis.conf配置redis跟随系统启动自动启动将redis_init_......
  • nginx获取response的cookie
    location/xxxxx/{proxy_passhttp://abc.com/;proxy_redirect http://abc.com/ http://abc.com/xxxxx/;proxy_set_headerCookie$http_cookie;proxy_cookie_path//xxxxx/;add_headerSet-Cookie"cookie_name=$upstream......
  • nginx服务
    server{server_nameerp.shudou.cnlisten80;location/{proxy_passhttp://127.0.0.1:8069;}}server{server_nameshudou.cnwww.shudou.cnlisten80;charsetutf-8;location/{includeuwsgi_params;uwsgi_pas......
  • 安装Nginx
    1,安装nginx这是官网:nginx:download,电脑64位所以下载了这个,Mainlineversion是NGINX的主要发行版本,它包含了最新的特性和更新。 2,C盘内存不多下载后可以放在D盘在D盘里新建一个文件夹nginx 3.打开cmd进入D盘cmd进来后如果是c盘,切换到D盘 4,通过nginx.exe启动,如果......
  • Django Nginx+uwsgi 安装配置
    DjangoNginx+uwsgi安装配置在前面的章节中我们使用pythonmanage.pyrunserver来运行服务器。这只适用测试环境中使用。正式发布的服务,我们需要一个可以稳定而持续的服务器,比如apache,Nginx,lighttpd等,本文将以Nginx为例。你也可以直接参考:Pythonuwsgi安装配置安......
  • Nginx Load
    1.180号端口监听跳转listen80;server_namelocalhost;rewrite^(.*)$https://$host$1permanent;##跳转1.2ssl配置listen443;server_namelocalhost;sslon;ssl_session_timeout5m;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_ciphersALL......
  • Linux(CentOS)之Nginx安装及配置
    一,复制nginx下载链接http://nginx.org/en/download.html二,下载nginx1.注意切换到root用户2.注意在/usr/local/目录下3.使用命令(PS:-c的参数即为上一步你复制的地址)wget-chttp://nginx.org/download/nginx-1.24.0.tar.gz三,解压tar-zxvfnginx-1.40.0.tar.gz四,安装依赖yumi......
  • nginx中一个请求匹配到多个location时的优先级问题,马失前蹄了
    背景为什么讲这么小的一个问题呢?因为今天在进行系统上线的时候遇到了这个问题。这次的上线动作还是比较大的,由于组织架构拆分,某个接入层服务需要在两个部门各自独立部署,以避免频繁的跨部门沟通,提升该接入层服务的变更效率。该接入层服务之前是使用cookie+内存session机制的,这......
  • 部署Nginx1.23脚本
    #!/bin/bashck_ok(){    if[$?-ne0]    then        echo"$1error."        exit1    fi}download_ng(){  cd /usr/local/src  if[-fnginx-1.23.0.tar.gz]  then    echo"当前目录已......
  • 电脑开不了机 电脑不开机 黑屏 电源灯亮 解决办法
    千万不要惊慌,千万不要惊慌,千万不要惊慌。90%的可能是电池没有电了。解决方法:插好电源,给电脑充20分钟,再点击开机键。一般情况下就会正常开机了。若开不了机,没关系,检测是否有电,换个充电器充30分钟看看。方法二:Fn+f7开启屏幕,或调解屏幕亮度,fn按住不放,不断点击f6。若以上都不行,......