Friday, December 26, 2014

Raspberry Pi web server setup.



Web server software setup.

There are two basic programs we want to install. Apache2 the web server and PHP a programming language for use with the server.

$ sudo apt-get install apache2 php5 libapache2-mod-php5 php5-cli

That will take a little while to install. Be patient.

Then you need to do a fix for the server.

$ sudo nano /etc/apache2/conf.d/name

For example set add ServerName localhost or any other name:

ServerName localhost

or you could use

Servername yourservername

Save the file and restart Apache 2

$ sudo service apache2 restart

Test the server:

Point a browser to the RPi You should get the setup page.

Now we need to test the PHP install..

$ cd /var/www

You should already see index.html with the code that shows you the home page.

Now we need to create a new page

$ sudo nano phpinfo.php


Save and exit. Now point your browser to yourhostname/phpinfo.php

You should get the PHP status page.


Now you should be ready to roll.

Note: you may need to edit /etc/apache2/apache2.conf and add:

# add php useage
AddHandler application/x-httpd-php .html


Create your web page and save it at /var/www

Index.html

<html>
<head>
<title> main page </title>
</head>
<body>
<center>
<h2>
Site under contruction
</h2>
<hr>
<img src='http://www.seemyheart.org/wp-content/uploads/2013/06/Website_Under_Construction.gif' eight=500 width=500 />

</center>
</body>
</html>

Update: Definitely left out the database part of a server. With MYSQL now being allegedly commercial, we wanted another choice. Oracle seems to have their fangs in all the major databases. We wanted to use Mariadb, but it does not seem to be in the repositories for the Raspberry Pi. We can also use freebasic to build our own database.

No comments:

Post a Comment