#Linux にブート スクリプトを追加するにはどうすればよいですか?
Linux で起動スクリプトを追加する方法:
システムの起動時にロードする必要がある設定ファイル
/etc/プロファイル、/root /.bash_profile
/etc/bashrc、/root/.bashrc
/etc/profile.d/*.sh、/etc/profile.d/lang.sh
/etc/ sysconfig/i18n、 /etc/rc.local (/etc/rc.d/rc.local)
1. ブート ファイルを変更します: /etc/rc.local (または /etc/rc) .d/rc .local)
# 1.编辑rc.local文件 [root@localhost ~]# vi /etc/rc.local # 2.修改rc.local文件,在 exit 0 前面加入以下命令。保存并退出。 /etc/init.d/mysqld start # mysql开机启动 /etc/init.d/nginx start # nginx开机启动 supervisord -c /etc/supervisor/supervisord.conf # supervisord开机启动 /bin/bash /server/scripts/test.sh >/dev/null 2>/dev/null # 3.最后修改rc.local文件的执行权限 [root@localhost ~]# chmod +x /etc/rc.local [root@localhost ~]# chmod 755 /etc/rc.local
2. シェル スクリプトを自分で作成します
作成したスクリプト (.sh ファイル) をディレクトリ /etc に配置します。 /profile.d/ の場合、このディレクトリ内のすべてのシェル スクリプトは、システムの起動後に自動的に実行されます。
3. chkconfig コマンドを使用して設定します
# 1.将(脚本)启动文件移动到 /etc/init.d/或者/etc/rc.d/init.d/目录下。(前者是后者的软连接) mv /www/wwwroot/test.sh /etc/rc.d/init.d # 2.启动文件前面务必添加如下三行代码,否侧会提示chkconfig不支持。 #!/bin/sh 告诉系统使用的shell,所以的shell脚本都是这样 #chkconfig: 35 20 80 分别代表运行级别,启动优先权,关闭优先权,此行代码必须 #description: http server 自己随便发挥!!!,此行代码必须 /bin/echo $(/bin/date +%F_%T) >> /tmp/test.log # 3.增加脚本的可执行权限 chmod +x /etc/rc.d/init.d/test.sh # 4.添加脚本到开机自动启动项目中。添加到chkconfig,开机自启动。 [root@localhost ~]# cd /etc/rc.d/init.d [root@localhost ~]# chkconfig --add test.sh [root@localhost ~]# chkconfig test.sh on # 5.关闭开机启动 [root@localhost ~]# chkconfig test.sh off # 6.从chkconfig管理中删除test.sh [root@localhost ~]# chkconfig --del test.sh # 7.查看chkconfig管理 [root@localhost ~]# chkconfig --list test.sh
4. サービス ファイルをカスタマイズし、システム サービスに追加し、Systemctl を使用して管理します
1. サービス ファイルを書き込みます: nginx.service、redis.service、supervisord.service
[Unit]:服务的说明 Description:描述服务 After:描述服务类别 [Service]服务运行参数的设置 Type=forking 是后台运行的形式 ExecStart 为服务的具体运行命令 ExecReload 为服务的重启命令 ExecStop 为服务的停止命令 PrivateTmp=True 表示给服务分配独立的临时空间 注意:启动、重启、停止命令全部要求使用绝对路径 [Install] 服务安装的相关设置,可设置为多用户 WantedBy=multi-user.target
2. ファイルをディレクトリに保存します: 754 権限。ディレクトリ パス: /usr/lib/systemd/system。たとえば、上記のvisord.serviceファイルはこのディレクトリに配置されます。
[root@localhost ~]# cat /usr/lib/systemd/system/nginx.service [root@localhost ~]# cat /usr/lib/systemd/system/supervisord.service
3. 起動時の自動起動を設定します(任意のディレクトリで実行)。起動コマンドの実行時にエラーが報告された場合は、systemctl daemon-reload
设置开机自启动 [root@localhost ~]# systemctl enable nginx.service [root@localhost ~]# systemctl enable supervisord 停止开机自启动 [root@localhost ~]# systemctl disable nginx.service [root@localhost ~]# systemctl disable supervisord 验证一下是否为开机启动 [root@localhost ~]# systemctl is-enabled nginx [root@localhost ~]# systemctl is-enabled supervisord
4を実行してください。その他のコマンド
启动nginx服务 [root@localhost ~]# systemctl start nginx.service 停止nginx服务 [root@localhost ~]# systemctl start nginx.service 重启nginx服务 [root@localhost ~]# systemctl restart nginx.service 查看nginx服务当前状态 [root@localhost ~]# systemctl status nginx.service 查看所有已启动的服务 [root@localhost ~]# systemctl list-units --type=service
5.サービスファイルの例:
# supervisord.service进程管理服务文件 [Unit] Description=Process Monitoring and Control Daemon # 内容自己定义:Description=Supervisor daemon After=rc-local.service nss-user-lookup.target [Service] Type=forking ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf ExecStop= /usr/bin/supervisorctl shutdown ExecReload=/usr/bin/supervisorctl reload Restart=on-failure RestartSec=42s KillMode=process [Install] WantedBy=multi-user.target
# nginx.service服务文件 [Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking 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 [Install] WantedBy=multi-user.target
# redis.service服务文件 [Unit] Description=Redis After=network.target remote-fs.target nss-lookup.target [Service] Type=forking ExecStart=/usr/local/bin/redis-server /etc/redis.conf ExecStop=kill -INT `cat /tmp/redis.pid` User=www Group=www [Install] WantedBy=multi-user.target
推奨チュートリアル: "linux ビデオ チュートリアル 》
以上がLinuxでブートスクリプトを追加するにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

在linux中,交叉编译是指在一个平台上生成另一个平台上的可执行代码,即编译源代码的平台和执行源代码编译后程序的平台是两个不同的平台。使用交叉编译的原因:1、目标系统没有能力在其上进行本地编译;2、有能力进行源代码编译的平台与目标平台不同。

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

MinGW - Minimalist GNU for Windows
このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境
