Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1
TABLE 22.1 apache2 Files and Folders

The installation process starts the Apache web server automatically, so there’s no need to manually
start the server. However, you can start and stop the server from the command prompt at any time, if
needed, using the service command. To stop the Apache web server, you use this command:


sudo service apache2 stop

Likewise, to restart the Apache web server, you use this command:


sudo service apache2 start

When you have the Apache web server running, you can test it. You can open a browser in the LXDE
desktop on your Raspberry Pi, or if you know the IP address of your Raspberry Pi, you can connect to
it from another client on the network.


If you’re connecting from the Raspberry Pi desktop, you can connect to the special localhost host
name:


http://localhost/

If you’re connecting from a remote client on your network, you need to know the IP address of your
Raspberry Pi. (The IP address may change if you’re using Dynamic Host Configuration Protocol
[DHCP] to assign addresses on your network.) To find the current IP address assigned to your
Raspberry Pi, you use the ifconfig command at the command prompt:


Click here to view code image


pi@raspberrypi ~ $ ifconfig

When you know the IP address assigned to your Raspberry Pi, you can connect to it from the remote
client by specifying the IP address as the URL. For example, if you found out that the IP address
assigned to your Raspberry is 10.0.1.70, you would use the URL:


http://10.0.1.70/

Either way, you should see the generic test webpage, which is shown in Figure 22.1.

Free download pdf