在Ubuntu上,您可以使用systemd来管理LNMP(Linux, Nginx, MySQL/MariaDB, PHP)服务的自动重启。以下是设置自动重启的步骤:
-
打开终端。
-
确保您已经安装了Nginx, MySQL/MariaDB和PHP。如果没有,请使用以下命令安装:
sudo apt update sudo apt install nginx mysql-server php-fpm -
启动Nginx, MySQL/MariaDB和PHP-FPM服务:
sudo systemctl start nginx sudo systemctl start mysql sudo systemctl start php7.4-fpm注意:如果您使用的是PHP 7.2,请将
php7.4-fpm替换为php7.2-fpm。 -
设置Nginx, MySQL/MariaDB和PHP-FPM服务开机自启:
sudo systemctl enable nginx sudo systemctl enable mysql sudo systemctl enable php7.4-fpm同样,如果您使用的是PHP 7.2,请将
php7.4-fpm替换为php7.2-fpm。
现在,您的LNMP服务已经设置为开机自启,当系统重启时,这些服务将自动启动。如果您需要手动重启这些服务,可以使用以下命令:
sudo systemctl restart nginx
sudo systemctl restart mysql
sudo systemctl restart php7.4-fpm
再次提醒,如果您使用的是PHP 7.2,请将php7.4-fpm替换为php7.2-fpm。
以上就是关于“LNMP在Ubuntu上如何设置自动重启”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm