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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.