Jump to content

restart apache, mysql,


stelthius

Recommended Posts

restart.html

 

<form name="restart" method="post" action="restart.php">
  <input type="submit" name="restartApache" value="Restart">
</form>

 

restart.php

 

<?php

if ( $_POST['restartApache'] )
   {
   if ( exec('/etc/init.d/apache2 restart') )
      {
      echo 'Apache service restarted!';
      }
   else
      {
      echo 'Service couldn\'t be restarted';
      }
   }
   else
   {

?>

<form name="restart" method="post" action="restart.php">
  <input type="submit" name="restartApache" value="Restart">
</form>

<?php

   }

?>

Link to comment
https://forums.phpfreaks.com/topic/115934-restart-apache-mysql/#findComment-596078
Share on other sites

Hmmm works nice but the only problem is the page will have like

 

Restart Apache

 

Restart MySQL

 

and then once it has restarted just say *Service Successfully restarted but remai on the same page if you get me i do have a peice of code already but it doesnt seem to work :(

Link to comment
https://forums.phpfreaks.com/topic/115934-restart-apache-mysql/#findComment-596087
Share on other sites

i actually got it to work like this,

 

 


<?php
                     if ($_GET['cmd'] == 'restartapache') 
                     if ( exec('/etc/init.d/httpd restart') )
                     {
                     echo '<font color=red>'.$lang_serrestarted.'</font>';
                     }
                     else
                     {
                     echo '<font color=green>Service couldn\'t be restarted</font>';
                     }
                     if ($_GET['cmd'] == 'restartmysql') 
                     if ( exec('/etc/init.d/mysqld restart') )
                     {
                     echo '<font color=red>'.$lang_serrestarted.'</font>';
                     }
                     else
                     {
                     echo '<font color=green>Service couldn\'t be restarted</font>';
                     }
		if ($_GET['cmd'] == 'restartftp') 
                     if ( exec('/etc/init.d/ftpd restart') )
                     {
                     echo '<font color=red>'.$lang_serrestarted.'</font>';
                     }
                     else
                     {
                     echo '<font color=green>Service couldn\'t be restarted</font>';
                     }
	}		


	?>
<br>
<br>
Restart Apache - <a href="?page=servercontrol&cmd=restartapache">Restart Apache</a><br />
<br />
Restart MySQL - <a href="?page=servercontrol&cmd=restartmysql">Restart MySQL</a><br />
<br />
Restart FTP - <a href="?page=servercontrol&cmd=restartftp">Restart FTP</a><br />

 

any tips on cleaning it up or making it more efficiant are welcome but it works and thats what i was aiming for :D

 

 

Rick.

Link to comment
https://forums.phpfreaks.com/topic/115934-restart-apache-mysql/#findComment-596109
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.