New Perspectives On Web Design

(C. Jardin) #1
By Paul Tero CHAPTER 8

To see a complex shell script, take a look at some of the startup scripts
in /etc/init.d. Use the less command to view a file. Press space to view
the next page or q to quit from less.


$ less /etc/init.d/apache2
#!/bin/sh
set -e
SCRIPTNAME="${0##*/}"...


The reason we’re really here, though, is to restart the Web server software.
If you logged into ssh as the administrative user root, you can run the restart
command directly. In this case, you will have been typing your commands
after a # instead of a $. If not, you’ll need to prefix it with the sudo command,
which says do some command as the super user. You’ll need the root
password to hand for sudo. To tell the Web server software to start, run:


$ sudo /etc/init.d/apache2 start
Password:
Starting apache2...


Hopefully this will fail with a useful error message. Hopefully, because
then you will know why it crashed in the first place, and you can plug the
error message into Google to find out how to fix it.
If it was unlucky enough to work, then your Web server is now running.
All the scripts in /etc/init.d run as background processes, or daemons
in UNIX parlance. This means that you can start them and they will stay
running even after you exit from ssh, turn off you computer and go to the
beach. This is unlike commands like traceroute and ls which do their
thing and finish. You can run netstat again to double-check the Web server
is now running. Notice the d at the end of apached. It stands for daemon.


netstat -tlpn | grep :80
tcp 0 0 :::80 ::: LISTEN 18201/apached
tcp6 0 0 127.0.0.1:8005 :::
LISTEN 22885/java

Free download pdf