【砖石局】Linux(CentOS7)中如何开启Nginx1.12.1、Redis3.2.5、FastDFS1.16服务开机自启动?

一、查看Linux中自启动服务列表
[root@localhost ~]#  

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

fdfs_storaged  	0:1:2:3:4:5:6:关
fdfs_trackerd  	0:1:2:3:4:5:6:关
netconsole     	0:1:2:3:4:5:6:关
network        	0:1:2:3:4:5:6:关
zookeeper      	0:1:2:3:4:5:6:
二、打开nginx-pid日志信息

去掉注释"# pid logs/nginx.pid"

[root@localhost conf]# pwd
/usr/local/nginx/conf
[root@localhost conf]# vim nginx.conf
.......
[root@localhost conf]# vim /etc/rc.d/rc.local 
//fastDFS启动命令
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
//nginx启动命令
/usr/local/nginx/sbin/nginx  
//redis启动命令
/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf

在这里插入图片描述
创建logs文件夹

[root@localhost nginx]# mkdir logs
[root@localhost nginx]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 129 10:54 conf
drwxr-xr-x. 2 root root   40 128 23:38 html
drwxr-xr-x. 2 root root    6 129 11:03 logs
drwxr-xr-x. 2 root root   19 128 23:38 sbin
三、编辑、保存rc.local文件
[root@localhost nginx]# vim /etc/rc.d/rc.local
-----------------------------------------------------------------------------------------
/usr/local/nginx/sbin/nginx

在这里插入图片描述
Esc退出编辑模式,命令“:wq”。

四、授权授权
[root@localhost etc]# chmod +x /etc/rc.d/rc.local
五、测试[步骤三]添加启动命令
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=2852
    
[root@localhost nginx]# ps -ef|grep nginx
root       2853      1  0 11:05 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody     2854   2853  0 11:05 ?        00:00:00 nginx: worker process
root       2887   1282  0 11:08 pts/1    00:00:00 grep --color=auto nginx


注意:关闭Linux防火墙
systemctl status firewalld //查看防火墙状态
systemctl start firewalld //开启防火墙
systemctl stop  firewalld
systemctl disable  firewalld //永久关闭防火墙

六、reboot重启虚拟机测试
[root@localhost ~]# ps -ef|grep nginx
root       1099      1  0 11:18 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody     1100   1099  0 11:18 ?        00:00:00 nginx: worker process
root       2445   2375  0 11:21 pts/0    00:00:00 grep --color=auto nginx

Nginx服务自启动成功!!!

♚学习、实战、总结、分享,让生活变得更美好!
☞林大侠博客:https://coding0110lin.blog.csdn.net/  欢迎转载,一起技术交流探讨!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值