How to Server Stop, Start, Restart (Apache, SSH, MySql, Qmail)

Server Stop, Start, Restart (Apache, SSH, MySql, Qmail)

Q. I’m using CentOS / RHEL / Fedora Linux server and I’d like to restart my httpd server after making some changes to httpd.conf file. How do I restart httpd?
A. You can use service command to restart httpd. Another option is use /etc/init.d/httpd service script.
Login as root user and type the following commands:

Task: Start httpd server:

# service httpd start

Task: Restart httpd server:

# service httpd restart

Task: Stop httpd server:

# service httpd stop
Please note that restart option is a shorthand way of stopping and then starting the Apache HTTPd Server. You need to restart server whenever you make changes to httpd.conf file. It is also good idea to check configuration error before typing restart option:
# httpd -t
# httpd -t -D DUMP_VHOSTS

Sample output:
Syntax OK
Now restart httpd server:
# service httpd restart
  • -t : Run syntax check for config files
  • -t -D DUMP_VHOSTS : Run syntax check for config files and show parsed settings only for vhost.

/etc/init.d/httpd script

You can also use following command:
# /etc/init.d/httpd restart
# /etc/init.d/httpd start
# /etc/init.d/httpd stop

A note about Debian / Ubuntu Linux

Type the following command under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

You can also use service command under Debian / Ubuntu Linux:
# service apache2 restart
# service apache2 stop
# service apache2 start


Q. How do I monitor my ssh server with monit? How do I restart ssh server if it does not respond or dead due to any issues under Linux?
A. You can easily monitor Linux server or service such as OpenSSH (SSHD daemon) using monit utility.

Monitor SSH and Auto Restart If Died

Open your /etc/monitrc or /etc/monit/monitrc file:
# vi /etc/monit/monitrc
Append following code:
check process sshd with pidfile /var/run/
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

Save and close the file. Make sure you set /var/run/ and /etc/init.d/ssh as per your Linux distribution. These values are valid for Debian / Ubuntu Linux. Restart monit to pickup the changes:
# /etc/init.d/monit restart


Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).
First login as root user. Now type the following command as per your Linux distro:

A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
 /etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start
# service mysqld stop
# service mysqld restart

(B) If you are using mysql on Debian / Ubuntu Linux then use following command:

* To start mysql server:
/etc/init.d/mysql start
* To stop mysql server:
/etc/init.d/mysql stop
* To restart mysql server
/etc/init.d/mysql restart


qmail-init(8) – Linux man page


qmail-init – start/stop scripts for qmail


init.d/qmail [ start | stop | restart | status ]
init.d/qmtpd [ start | stop | restart | status ]
init.d/pop3d [ start | stop | restart | status ]
init.d/qmqpd [ start | stop | restart | status ]
init.d/qmtpd [ start | stop | restart | status ]
init.d/smtpd [ start | stop | restart | status ]


These init scripts are responsible for starting and stopping the three main qmail services. init.d/qmail invokes qmail-start (the main qmail delivery agent), init.d/pop3d invokes qmail-popupcheckpassword, and qmail-pop3d (the POP3 server system for qmail) by way of tcpserverinit.d/qmqpd invokes qmail-qmqpd (the QMQP server for qmail — a specialized null-client protocol) by way of tpcserverinit.d/qmtpd invokes qmail-qmtpd (the QMTP server for qmail — a high-speed alternative to SMTP) by way of tcpserver, and init.d/smtpd invokes qmail-smtpd (the SMTP daemon for qmail) by way of tcpserver, as well as optionally invoking rblsmtpd if that package is installed.
These files typically reside in either /etc/rc.d/init.d (most systems using SysV-style init scripts) or /etc/init.d (Solaris).

Control Files

Default delivery instructions. Default: ./Mailbox. The contents of this file are used as the default delivery instructions for any legitimate local address that has either nonexistant or empty delivery instructions. See dot-qmail(5) for details on the contents. To emulate the typical sendmail and procmail combined configuration, install the dot-forward and procmail packages (and ensure they and preline are in the path), and put the following lines in this file: |dot-forward .forward
|preline procmail
If antirbl is installed, this file contains a list of domains for which to disable RBL testing. Default: empty.
The password checking program for all systems that require one (currently only init.d/pop3d) Default: checkpassword.
Maximum number of simultaneous inbound POP3 connections. Default: 20.
Maximum number of simultaneous inbound QMQP connections. Default: 20.
Maximum number of simultaneous inbound QMTP connections. Default: 20.
Maximum number of simultaneous inbound SMTP connections. Default: 20.
The program that is to be used for message logging. Default: splogger. It is started in the /var/log directory. If the string contains {}, then it replaced with the name of the system being logged (such as qmail or pop3d), otherwise the system name is appended to the string. To use multilog ensure that a subdirectory in /var/log exists for each of the systems and put the following in this file: multilog -t {}
If rblsmtpd is installed, this file lists the RBL domain servers on which to do lookups. Default:
If rblsmtpd is installed, this file sets the timeout value. Default: 60.
The maximum amount of CPU time an individual daemon process (pop3d, qmqpd, qmtpd, or smtpd) is allowed to consume before it is terminated, in seconds. Default: unlimited.
The maximum data segment size of an individual daemon process, in kilobytes. Default: unlimited.

Popular posts from this blog

How to Delete WHM Mail Queue through SSH sent from a particular sender

how to change witribe wlan password? how to secure your witribe router

How to Delete all logs in a cpanel server - SSH