LinuxDeploy里的Ubuntu自启动nginx(适用于其他软件)

网上的教程是这样的,基本能用

1.编写脚本(这个文件及其内容安装Nginx后自动生成,没有的话内容自己Google)
$ sudo vi /etc/init.d/nginx

这样在控制台就很容易的操作nginx了:查看Nginx当前状态、启动Nginx、停止Nginx、重启Nginx…

android@localhost:~$ /etc/init.d/nginx
Usage: nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}
android@localhost:~$ /etc/init.d/nginx start
* Starting nginx nginx                                                                                                               [fail]
android@localhost:~$ /etc/init.d/nginx status
* nginx is running
android@localhost:~$
2.将 “ /etc/init.d/nginx start” 命令加入到 “/etc/rc.local” 文件中,这样开机的时候nginx就默认启动了

由于我的Ubuntu里没有 “rc.local” 文件,因此需要自己做一个

1.自行创建 /etc/rc.local 添加以下默认内容(在 exit 0 之前加入自定义内容)
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
2.执行以下命令确保 rc.local 开机自启
sudo chown root:root /etc/rc.local
sudo chmod 755 /etc/rc.local
sudo systemctl enable rc-local.service

但是由于这个系统是运行在容器里的,没法用 “systemctl”

Running in chroot, ignoring request.

难道就没办法了吗?

当然不会,诀窍就在手机上Linux Deploy 这个APP里

1.点击右下角的设置图标进入设置界面
2.划到“初始化”那块,“启用”打上勾

初始化系统里面有两个选项,分别为“run-parts”和“sysv”,不知道是干什么用的。不必管他,默认即可(我的默认是“run-parts”)。

3.进入“初始化设置”选项,看到什么了?惊不惊喜!

初始化路径 —> /etc/rc.local

就是这样,一般情况下只要把“初始化”打上勾就行了,这样就可以开机自动执行“rc.local”文件里的内容了,就是这么简单

最新文章

  1. jQuery Mobile学习之grid、等待显示的ajax效果、页面跳转、页面跳转传递参数等(二)
  2. javascript 中的getter,setter
  3. hadoop日志太大
  4. POJ 2057 The Lost House
  5. php get_magic_quotes_gpc() addslashes()
  6. 熬之滴水成石:最想深入了解的内容--windows内核机制(15)
  7. window.open()详解及浏览器兼容性问题
  8. Spring学习(15)--- 基于Java类的配置Bean 之 @Bean & @Scope 注解
  9. UTC、GTC时间和本地时间
  10. centos中redis安装
  11. ROS * 了解xacro的编写
  12. tar: Removing leading `/' from member names
  13. [转] libtool的作用及应用
  14. MySql重复查询
  15. Android ProgressBar的使用
  16. SpringCloud之Eureka(注册中心集群篇)
  17. bzoj 3678 wangxz与OJ
  18. jquery -- body div 和 body>div 的区别
  19. 十分钟搭建和使用sonarqube代码质量管理平台
  20. ES6 对象转Map

热门文章

  1. Ubuntu Server安装telnet服务时"Unable to locate package telnetd"解决方法
  2. View epub and mobi File on Linux
  3. DrJava试用笔记
  4. STM32启动代码分析及其汇编学习-ARM
  5. Mybatis源码解析2—— 实例搭建
  6. Java基础技术多线程与并发面试【笔记】
  7. 【笔记】numpy.array基础(2)
  8. ubunt中,使用命令su命令切换root账户,提示认证失败
  9. Hibernate5 入门之SessionFactory对象的创建
  10. 跨域@RequestBody@RequestParam 和JSON.stringify