Home  >  Article  >  Backend Development  >  About common functions of php controlling linux server

About common functions of php controlling linux server

不言
不言Original
2018-06-15 14:22:101873browse

This article mainly introduces the common functions of controlling the Linux server with PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

The server host is CentOS. Every time Restarting and shutting down have to be connected through the client. I would like to ask if the shutdown and restart operations of the system can be realized through the PHP page

There is a system method in php, which can call system commands.
First create a script (eg /root/reboot_server.sh) for restarting.

#!/bin/bash 
reboot

Give him permissions 4755
chown root:root /root/reboot_server.sh
chmod 4755 /root/reboot_server.sh
chmod 4777 /sbin/reboot

In php, find a way to make the following call

<?php 
system("/root/reboot_server.sh"); 
?>

Other functions are similar! Install a virtual machine yourself and play! Don’t really hang up on the server

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to solve the problem of PHP scheduled sending service

The above is the detailed content of About common functions of php controlling linux server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn