Starting and Stopping the Apache Server as the SuperUser
To start Apache, use the following command:
$ sudo apachectl start (c as in current, t as in table, l as in Linux)
To stop Apache, use this command:
$ sudo apachectl stop (c as in current, t as in table, l as in Linux)
Start Apache now. Test your PHP installation by navigating to the htdocs directory, the default location from which Apache serves public files to the world:
$ sudo apachectl start
// change to the Apache public htdocs directory
$ cd /var/www/htdocs
// list all files in the directory
$ ls
To confirm that Apache is running locally, start the OpenBSD default text browser Lynx (http and https) to surf from your console to the Apache server running as localhost.
$ lynx 127.0.0.1
You should see the Apache default index.html congratulations screen. Enter q to quit Lynx.
Test PHP by creating a new index.php file that includes the line <?php phpinfo(); ?> $ sudo vi index.html.
Beneath the <body bgcolor="#ffffff"> tag, insert the line:
<?php phpinfo(); ?>
Then save the index.php file with your changes:
ESC:wq! index.php.
 | |
Figure 1. Running OpenBSD-powered Apache, MySQL, and PHP Web Server: Apache is now loaded with the PHP module, and mySQLi provides the functions for MySQL database connectivity. |
Test this out from the server console with the default installed Lynx text browser. For security reasons, OpenBSD does not ship with a graphical browser enabled. To further test that your Apache-powered OpenBSD machine is serving documents, enter the IP address of your server machine into a LAN-connected computer's browser URL field. Enter the server's LAN IP address or fully qualified domain name into your client machine browser URL field (this value was entered into the Apache httpd.conf file previously):
// secure lynx browser on localhost
$ lynx 127.0.0.1/index.php
// LAN connected Client Browser URL
http://192.168.1.16 or http://www.fullyqualifieddomain.com
Depending on your configuration choices, you should now be serving the Apache congratulations screen with PHP information across your LAN or to the Internet at large.
Test index.php by using another computer on your local network and entering the IP address of the ServerName or DNS-resolving ServerName that was set in the Apache configuration file /var/www/conf/httpd.conf (for example, http://192.168.1.16).
Congratulations! Apache is now loaded with the PHP module, and mySQLi provides the functions for MySQL database connectivity (see Figure 1). You are now running an OpenBSD-powered Apache, MySQL, and PHP web server! See Listing 1. Auto Loading MySQL and Apache Https on Boot for an auto-load enhancement to your configuration.