This is a summary of what I did to setup a server on my raspberry Pi. This is based on previous post on the same topic and this link:
http://www.instructables.com/id/Raspberry-Pi-Web-Server/
Before starting, make sure that your raspberry software are updated and let us install the VIM editor as well:
sudo apt-get update sudo apt-get install vim |
This post is not about vim but if you want to have a go, here are a few commands. First, type the character i to enter into the insert mode to be able to start editing. To save, press ESC key followed by :w. To enter the insert mode again; type i. To save and quit, type ESC followed by :wq. That’s it for the vim tutorial. Let us go back to the raspberry server.
hostname
The first step proposed in the link above is to setup a hostname for your computer. I should admit that it did not work for me but I do not mind to use the IP address. I’ll put the information for bookkeeping.
First, let us edit the dhclient.conf file
sudo -i vim /etc/dhcp/dhclient.conf |
Now look for the line “#send host-name “xxxxxx”;” (on the raspberry version I used, xxxxxx is andare.fugue.com), and remove the “#” symbol from in front of it. Now press Esc key, and type “:wq” to save the changes.
Back in the shell, type:
hostname xxxxxx # where "xxxxxx" is what you want to call your server |
Finally for this step, type
ifdown eth0 ifup eth0 |
Now to reboot the system type
halt |
Once you have started the raspberry pi again, change the password::
sudo -i passwd pi |
Install apache
sudo apt-get install apache2 php5 libapache2-mod-php5 |
you may get a few warnings (could not reliably determine the server’s full qualified name for servername). You may ignore them. I got the warning but the server works.
The group may be already setup but it does not cost anything to check:
sudo groupadd www-data sudo usermod -g www-data www-data |
then open a browser and type http://localhost
To enable htaccess files you must modify the config files::
sudo vim /etc/apache2/sites-enabled/000-default" |
You’ll see a line like the following:
AllowOverride None |
change it to
AllowOverride ALL |
Mysql
sudo apt-get install mysql-server mysql-client php5-mysql |
It may take a while. When asked for a password, enter one and confirm it.
install an FTP server
In order to upload files on your FTP server, type in
sudo chown -R pi /var/www |
Then, install this tool:
sudo apt-get install vsftpd |
And edit its configuration file:
sudo vim /etc/vsftpd.conf |
Search through the file and change the following lines:
anonymous_enable=YES Change To anonymous_enable=NO
and uncomment these lines (remove the hash )
#local_enable=YES #write_enable=YES |
Also, add a line to the bottom of the file:
force_dot_files=YES |
Now restart the FTP server with
sudo service vsftpd restart |
Now you are able to connect to your Raspberry Pi with an FTP client, using the following information:
Host: (Hostname you set up or IP address)
Username: pi
Password: (Password you set previously)
Port: 21
CGI Python script configuration
edit the file /etc/apache2/sites-enabled/000-default and adapt the section related to CGI script as follows:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all AddHandler cgi-script .py </Directory> |
Create the directory and change the permission:
mkdir /var/www/cgi-bin chmod 755 /var/www/cgi-bin |
You can try this sctipt:
#!/usr/bin/env python # -*- coding: UTF-8 -*- import cgi def main(): print "Content-type: text/html\n" form = cgi.FieldStorage() print "<h1>Test photo</h1>" main() |
Pingback: RasPi links | GANESH