LNMP在Ubuntu上如何设置自动重启
导读:在Ubuntu上,您可以使用systemd来管理LNMP(Linux, Nginx, MySQL/MariaDB, PHP)服务的自动重启。以下是设置自动重启的步骤: 打开终端。 确保您已经安装了Nginx, MySQL/Maria...
在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
。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: LNMP在Ubuntu上如何设置自动重启
本文地址: https://pptw.com/jishu/732958.html