Home > php教程 > PHP源码 > body text

用PHP来运行centos系统命令

PHP中文网
Release: 2016-05-25 17:12:33
Original
1183 people have browsed it

步骤如下: 

vi /etc/sudoers 
加上一句 apache  ALL=(ALL)       NOPASSWD: ALL 

然后在php中加上sudo就可以执行任何命令了 

exec("sudo reboot");
?> 


如果系统运行sudo 反应速度非常慢 

可以进行如下操作进行提升速度 

用"hostname "命令查看当前主机的主机名称。例如,该命令返回"www.siteyun.com ".

再用vi打开"/etc/hosts"文件,并将"ddx.net"加入到 "127.0.0.1"这行中。

例如:

127.0.0.1               www.siteyun.com localhost.localdomain localhost

保存搞定。

本人用PHP来控制一些服务器重启,及些服务的重启等操作


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!