Quick setup of webserver


35 posts   Page 1 of 2   1, 2
by TonAu » Sat Jul 21, 2012 11:57 am
This is my "steps to setup" file I compiled from advices all over the internet.

Problem is that you find many advices for your total setup, and then the question is:
which part did I use from which website?

It makes a webserver that displays a page from which a LED can be switched on and off.
Very simple basics, but the steps are there, and can be followed. Easy when you update or change SD card or just want to clean up and start fresh.

Google on parts of the text will probably give the original websites


Step 1 Download Image

a. Download the image from a mirror or torrent http://www.raspberrypi.org/downloads
b. Extract the image file debianXXXXXX.img from the debianXXXXXXdirectory in the debianXXXXXX.zip
c. Insert the SD card into your SD card reader and check what drive letter it was assigned. You can easily see the drive letter (for example G:) by looking in the left column of Windows Explorer.
d. Download the Win32DiskImager utility. The download links are on the right hand side of the page, you want the binary zip.
e. Extract the zip file and run the Win32DiskImager utility. You may need to run the utility as Administrator.
f. Select the debianXXXXXX.img image file you extracted earlier
g. Select the drive letter of the SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy your computer's hard disk!
h. Click Write and wait for the write to complete.
i. Exit the imager and eject the SD card.
j. Insert the card in the Raspberry Pi, power it on, and it should boot up. Have fun!

Step 2 Startup

- Enable SSH
- Reformat to use all the space on SD Card

Step 3 Change the hostname: After SAMBA this works

!! do this from the HDMI screen... eth0 must go down and up
"sudo -i" [Return / Enter key]
"nano /etc/dhcp/dhclient.conf" [Return / Enter key]
Now look for the line "#send host-name "xxxxxx";" (on mine, xxxxxx is andare.fugue.com), and remove the "#" symbol from in front of it.
Then type "hostname xxxxxx" where "xxxxxx" is what you want to call your server (I chose "raspberryPi" to make it easy).
Please Note that you cannot have any spaces in the hostname.

Finally for this step, type in "ifdown eth0" and hit Return / Enter.
Once that has finished, type "ifup eth0" and hit Return / Enter.

To change the default password, start an SSH session (* Putty to IP nbr *), and login,
then type "sudo -i", hit Return / Enter,
then type "passwd pi" and hit Return / Enter.
Then you can type in your new password, it will ask you to confirm the password.


Step 4 Install Apache with PHP

Type in "sudo apt-get update"
Once this is complete, you may receive an error, just run the same command again to resolve this.

Then type "sudo apt-get install apache2 php5 libapache2-mod-php5"
It will say "Do you want to continue", just press "y" and hit Return / Enter.

Wait for this to finish (as it may take a while).
When it is finished, you may have noticed that there was an error, to solve this,
type "sudo groupadd www-data", then
"sudo usermod -g www-data www-data".
Now restart apache with
"sudo service apache2 restart". This time there should be no errors.

If you now start a web browser on your computer, and type your hostname into the address bar, you will get the apache installed page.

To enable htaccess files you must modify the config files, like so:
Type "sudo nano /etc/apache2/sites-enabled/000-default" and hit Return / Enter.
You'll see a line like the following:
"AllowOverride None" - change this to "AllowOverride ALL". (see image for more detail)
Then hold the Ctrl button and press the "x" key, then press "y" when prompted and hit Return / Enter.
Now restart apache with "sudo service apache2 restart".

Step 5 Install MySQL

Type in "sudo apt-get install mysql-server mysql-client php5-mysql" and hit Return / Enter.
You will be asked "Do you want to continue?", press the "y" key, then Return / Enter.
This will take a while to download and install, but a screen will appear asking you to set
"New password for the MySQL "root" user", enter a password, then confirm it. Password: root
Again, wait a while, then you're done.

Step 6 Install an FTP server

Type in "sudo chown -R pi /var/www" <-- IMPORTANT (otherwise you won't be able to upload anything)
Type in "sudo apt-get install vsftpd" and hit Return / Enter
Now type in "sudo nano /etc/vsftpd.conf" and hit Return / Enter

Search through the file and change the following lines:
anonymous_enable=YES Change To anonymous_enable=NO
#local_enable=YES Change To local_enable=YES
#write_enable=YES Change To write_enable=YES
#local_umask=022 Change to local_umask=022

Also, add a line to the bottom of the file:
force_dot_files=YES

Then hold the Ctrl key and press "x", then "y", then the Return / Enter key.

Now restart the FTP server with
"sudo service vsftpd restart"

At the moment you will need to change the directory every time you login by FTP, to solve this:

% THIS DID NOT WORK WELL, MAYBE BECAUSE PI WAS LOGGED IN THE MAIN (HDMI) SCREEN?
% Type:
% "sudo -i"
% "passwd root"
% Type in any password (this is only temporary)
% "exit"
% "exit"
%
% Start a new SSH session
% Username: root
% Password (the one you just set)
% "nano /etc/passwd"
% find the line "pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash" and change it to "#pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash".
% Then hold the Ctrl key and press "x", then release Ctrl and press "y" then hit Return / Enter.
% "usermod -d /var/www pi"
%
% Now close the SSH session, and start a new one with username: pi and your password, and type the following:
%
% "sudo -i"
% "usermod -L root"
% "exit"

Now you are able to connect to your Raspberry Pi with an FTP client, using the following information:
Host: (Hostname you set - I used raspberryPi)
Username: pi
Password: (Password you set previously)
Port: 21

Step 7 Installing phpMyAdmin

Installing phpMyAdmin is a simple task.
1. Go to http://www.phpmyadmin.net
2. Download the zip file
3. Extract it to a folder
4. Upload the extracted files to your server (you may need to set permissions)

Step 8 Tightvncserver

Log in to your Pi and install the Tight VNC Package
"sudo apt-get install tightvncserver"

Next Run TightVNC Server which will prompt you to enter a Password and an optional View Only Password
"tightvncserver"

Once that is done you can run it straight from the prompt I am using 1920x1080 which is my monitor maximum resolution.
"vncserver :1 -geometry 1920x1080 -depth 24"

Or you could create a script to save typing in the whole thing.
"nano svnc.sh" (call the file whatever you like)

Add the lines:
Code: Select all
#!/bin/sh
vncserver :1 -geometry 1920x1080 -depth 24


Ctrl-x y <return> (To Exit Nano and Save)

Set the file to Execute
"chmod +x svnc.sh"

then to run
" ./svnc.sh"

Run at boot:

Start a root session
"sudo bash" % I did sudo nano

Create a file in /etc/init.d with a suitable name such as vncboot with the following content.
Code: Select all
### BEGIN INIT INFO
# Provides:          vncboot
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start VNC Server at boot time
# Description:       Start VNC Server at boot time.
### END INIT INFO

#! /bin/sh
# /etc/init.d/vncboot

USER=root
HOME=/root

export USER HOME

case "$1" in
 start)
   echo "Starting VNC Server"
   #Insert your favoured settings for a VNC session
   /usr/bin/vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565
   ;;

 stop)
   echo "Stopping VNC Server"
   /usr/bin/vncserver -kill :1
   ;;

 *)
   echo "Usage: /etc/init.d/vncboot {start|stop}"
   exit 1
   ;;
esac

exit 0



Modify the file permissions so it can be executed
"chmod 755 /etc/init.d/vncboot"

%Enable dependency based boot sequencing
%"update-rc.d /etc/init.d/vncboot defaults"
%
%If enabling dependency based boot sequencing was successful, it says
% update-rc.d: using dependency based boot sequencing
%
%But if it says
%update-rc.d: error: unable to read /etc/init.d//etc/init.d/vncboot
%
%then try the following command
update-rc.d vncboot defaults

Reboot your Raspberry PI and you should find a vncserver already started.

Here I start VNCServer up from commandline first, so that pw is set. VNC client can not set that.

Step 9 make apache be able to execute GPIO commands
Use visudo to modify sudoers to:

Code: Select all
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset
Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE DISPLAY PATH"
Defaults exempt_group = users

# Host alias specification

# User alias specification
User_Alias APACHE = www-data

# Cmnd alias specification
Cmnd_Alias GPIOSTUFF = /home/pi/tog1


# User privilege specification
root   ALL=(ALL) ALL
suse   ALL=(ALL) ALL
pi   ALL=(ALL) ALL
APACHE   ALL=(ALL) NOPASSWD: GPIOSTUFF

# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%users ALL=(ALL) ALL



Step 10, Create a command to control a LED between pin 5 and 6 of GPIO port.

LED CONNECTION:
Use a led and a resistor of 270Ohm .
Cathode of led connects to pin 6,
Anode to resistor
other side of resistor to pin 5.


make a new file in /home/pi called tog1.c and copy this content in


Code: Select all
/*
  * gpio_relay.c - example of driving a relay using the GPIO peripheral on a BCM2835 (Raspberry Pi)
  *
  * Copyright 2012 Kevin Sangeelee.
  * Released as GPLv2, see <http://www.gnu.org/licenses/>
  *
  * Modified by Ton Augustin for very simple RPi setup: Use Bit 1 instead of Bit 17
 
  * This is intended as an example of using Raspberry Pi hardware registers to drive a relay using GPIO. Use at your own
  * risk or not at all. As far as possible, I've omitted anything that doesn't relate to the Raspi registers. There are more
  * conventional ways of doing this using kernel drivers.
  */
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>

#define IOBASE   0x20000000

#define GPIO_BASE (IOBASE + 0x200000)

#define GPFSEL0    *(gpio.addr + 0)
#define GPFSEL1    *(gpio.addr + 1)
#define GPFSEL2    *(gpio.addr + 2)
#define GPFSEL3    *(gpio.addr + 3)
#define GPFSEL4    *(gpio.addr + 4)
#define GPFSEL5    *(gpio.addr + 5)
// Reserved @ word offset 6
#define GPSET0    *(gpio.addr + 7)
#define GPSET1    *(gpio.addr + 8)
// Reserved @ word offset 9
#define GPCLR0    *(gpio.addr + 10)
#define GPCLR1    *(gpio.addr + 11)
// Reserved @ word offset 12
#define GPLEV0    *(gpio.addr + 13)
#define GPLEV1    *(gpio.addr + 14)

#define BIT_1  (1 << 1)
#define BIT_17 (1 << 17)

#define PAGESIZE 4096
#define BLOCK_SIZE 4096

struct bcm2835_peripheral {
    unsigned long addr_p;
    int mem_fd;
    void *map;
    volatile unsigned int *addr;
};

struct bcm2835_peripheral gpio = {GPIO_BASE};

// Some forward declarations...
int map_peripheral(struct bcm2835_peripheral *p);
void unmap_peripheral(struct bcm2835_peripheral *p);

int gpio_state = -1;

////////////////
//  main()
////////////////
int main(int argc, char *argv[]) {

    if(argc == 2) {
        if(!strcmp(argv[1], "on"))
            gpio_state = 1;
        if(!strcmp(argv[1], "off"))
            gpio_state = 0;
    }

    if(map_peripheral(&gpio) == -1) {
        printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
        return -1;
    }

    /* Set GPIO 17/1 as an output pin */
    GPFSEL0 &= ~(7 << 3); // Mask out bits 5-3 of GPFSEL0 (i.e. force to zero)
    GPFSEL0 |= (1 << 3);  // Set bits 5-3 of GPFSEL0 to binary '001'

    if(gpio_state == 0)
        GPCLR0 = BIT_1;
    else if(gpio_state == 1)
        GPSET0 = BIT_1;

    usleep(1);    // Delay to allow any change in state to be reflected in the LEVn, register bit.

    printf("GPIO 1 is %s\n", (GPLEV0 & BIT_1) ? "high" : "low");

    unmap_peripheral(&gpio);

    // Done!
}

// Exposes the physical address defined in the passed structure using mmap on /dev/mem
int map_peripheral(struct bcm2835_peripheral *p)
{
   // Open /dev/mem
   if ((p->mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
      printf("Failed to open /dev/mem, try checking permissions.\n");
      return -1;
   }

   p->map = mmap(
      NULL,
      BLOCK_SIZE,
      PROT_READ|PROT_WRITE,
      MAP_SHARED,
      p->mem_fd,  // File descriptor to physical memory virtual file '/dev/mem'
      p->addr_p      // Address in physical map that we want this memory block to expose
   );

   if (p->map == MAP_FAILED) {
        perror("mmap");
        return -1;
   }

   p->addr = (volatile unsigned int *)p->map;

   return 0;
}

void unmap_peripheral(struct bcm2835_peripheral *p) {

    munmap(p->map, BLOCK_SIZE);
    close(p->mem_fd);
}

compile with
"cc tog1.c"
Test with
" ./a.out on"
" ./a.out off"

rename a.out to tog1
"mv ./a.out ./tog1"



Step 11, a php file

Create a php file
tog.php:

Code: Select all
<html>
<head>
</head>
<body>
<?php
if (array_key_exists('submit_check',$_POST) && ($_POST['submit_check'] != "0") ) {
   if (array_key_exists('on',$_POST)) {
      echo shell_exec("sudo /home/pi/tog1 on 2>&1");
   }
   if (array_key_exists('off',$_POST)) {
      echo shell_exec("sudo /home/pi/tog1 off 2>&1");
   }
}

?>


<form method="post">
<input type="hidden" name="submit_check" value="1"/>

<input type="submit" name="on" value="on"  />


<input type="submit" name="off" value="off"  />

 </form>


</body>
</html>


and play with it from a webbrowser


Step 12 samba

"sudo apt-get install samba"

save org conf file:
"sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old"

"sudo nano /etc/samba/smb.conf"
Search for the section marked ##### Authentication #####
Change the text
# security = user
to
security = user

"sudo /etc/init.d/samba restart"
"sudo nano /etc/samba/smb.conf"

Search for the section starting [homes]
In the [homes] section, change from
read only = yes
to
read only = no

"sudo /etc/init.d/samba restart"
"sudo apt-get install samba-common-bin"
"sudo smbpasswd -a pi"
"sudo mkdir /home/shares"
"sudo mkdir /home/shares/public"
"sudo chown -R root:users /home/shares/public"
"sudo chmod -R ug=rwx,o=rx /home/shares/public"

"sudo nano /etc/samba/smb.conf"
In smb.conf change WORKGROUP to your workgroup
append at end of file:
[public]
comment = Public Storage
path = /home/shares/public
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no

[edit obarthel: fixed "./tog1"]
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by davec » Sat Jul 21, 2012 8:53 pm
thanks for this. just found it whilst searching, and being the n00b that I am, its saved me a lot of further searching.
Posts: 3
Joined: Thu Apr 12, 2012 10:44 am
by TonAu » Mon Jul 23, 2012 7:51 pm
A small type in the above:

rename a.out to tog1
Code: Select all
"mv ./a.out  /tog1"

Should be

Code: Select all
"mv ./a.out ./tog1"


Notice that there should a dot in front of ./tog1
Also Notice that the tog1.c file should be in the /home/pi dir. The "CC" command should also be given in the /home/pi directory
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by KCarscadden » Mon Jul 23, 2012 8:59 pm
TonAU

Note that you can edit your original post to make the correction, rather than having the correction in a new post. The edit url should be on the top line of the post.
Posts: 49
Joined: Sat Jun 09, 2012 9:00 pm
Location: Canada
by TonAu » Mon Jul 23, 2012 9:12 pm
KCarscadden

I can not find that edit link. Where should it be? I am using IE
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by KCarscadden » Tue Jul 24, 2012 1:31 am
Sorry TonAU, the ability to edit your own posts appears to have disappeared. Perhaps edit is only available in some forums or for a limited time after the post is created.

Edit: Appears to be the 2nd reason - I am able to edit this post just after creating it.
Posts: 49
Joined: Sat Jun 09, 2012 9:00 pm
Location: Canada
by alexeames » Tue Jul 24, 2012 7:12 am
KCarscadden wrote:Sorry TonAU, the ability to edit your own posts appears to have disappeared. Perhaps edit is only available in some forums or for a limited time after the post is created.

Edit: Appears to be the 2nd reason - I am able to edit this post just after creating it.


You get half an hour on here before the edit window closes. It's a bit of a nuisance, but it also prevents other bad stuff from being done, so it's a bit of a knife-edge balance. If you want to write a procedure that may change with updates etc. so you can edit it later you'd be better off putting it on the wiki.
My Pi uses 2 watts - what what? ---- HiRes early production Pi photos RS Front Back | Farnell Front Back
User avatar
Posts: 2018
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
by edas » Fri Jul 27, 2012 1:10 am
Hello and thanks for your tutorial !


Please help me i keep getting these messages when i try to run the compiled file

Failed to map the physical GPIO registers into the virtual memory
Failed to open /dev/mem, try checking permissions.


Thanks for your help
Posts: 5
Joined: Fri Jul 27, 2012 12:55 am
by TonAu » Fri Jul 27, 2012 7:20 am
edas wrote:Hello and thanks for your tutorial !


Please help me i keep getting these messages when i try to run the compiled file

Failed to map the physical GPIO registers into the virtual memory
Failed to open /dev/mem, try checking permissions.


Thanks for your help


Hi edas,
The compiling did go ok. You should test with sudo. So:


Test with
"sudo ./a.out on"
"sudo ./a.out off"

Thanks for noticing.

Later when the command is given by the webserver, the sudoers file takes care of a 'sudo' for the webserver.
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by edas » Mon Jul 30, 2012 3:28 pm
Hi TonAu

Ok compiling worked thanks!,

now i can execute from the commandline and it works !

but if button is press on the website it gives back
"sudo: no tty present and no askpass program specified"

google tells me that its something with the sudoers file ??!!

Thanks again for your help :)
Posts: 5
Joined: Fri Jul 27, 2012 12:55 am
by TonAu » Mon Jul 30, 2012 6:18 pm
Hi edas,

Check for typos first please.. the error message is a standard error message of sudo. (I get it also when I rename my tog1 temporarily to tog2)

Are you sure you renamed a.out to tog1 (no extension) and is it now in the /home/pi directory?

Are you sure you have
echo shell_exec("sudo /home/pi/tog1 on 2>&1"); (and the off as well) in the php file?
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by edas » Thu Aug 02, 2012 6:12 pm
I just retry your tutorial from begin to end and it works straight ahead now!!
before i just didnt follow everything right

Thanks!!!
Posts: 5
Joined: Fri Jul 27, 2012 12:55 am
by edas » Thu Aug 02, 2012 6:17 pm
Hi,
My next question how to add more buttons for controlling the other gpio's

Is this done from the php side only or also in tog1.c?

can you make a example ?


Thanks for your time
Posts: 5
Joined: Fri Jul 27, 2012 12:55 am
by TonAu » Thu Aug 02, 2012 7:57 pm
There are two ways that can be followed:
First:
Make a tog2, tog3 tog4 etc for every port one command.
You have to copy and then modify the code of tog1.c so it adresses another port.
This is some digging into the BCM2835-ARM-Peripherals.pdf for the right values for the registers, specificly GPFSEL0,GPFSEL1, GPFSEL2, GPCLR0 and GPSET0. Check chapter 6 GPIO.
So when you have more tog files, tog1, tog2 etc. you need to call them from php
Now the buttons are named "on" and "off". Copy and rename to "on1" "off1" "on2" "off2" etc.
In the if (array_key_exists('submit_check' part, add checks for the right buttons and call the right command.
Do not forget to add tog2 and further in sudoers, to the GPIOSTUFF

The second way would be to add a parameter to tog1, so that you do tog {portnumber} {on/off}
That would look nicer, but requires more programming, is more difficult, both in C and PHP. But feel challenged to do it! :)
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by edas » Fri Aug 03, 2012 12:06 am
Hi TonAu

In de tog2.c file, Do i have to change the IOBASE adres or the *(gpio.addr + 0)

Thanks alot
Posts: 5
Joined: Fri Jul 27, 2012 12:55 am
by TonAu » Fri Aug 03, 2012 6:39 am
Search the internet for BCM2835-ARM-Peripherals.pdf.
Save the file, it will be your friend in the coming hours.
Find chapter 6 GPIO page 89, that is the interesting part for this.

There are two things that need to be changed:
1 - make the port an output, so you can drive the LED
2 - set the correct port to the value 1 or 0.


1. Make the port an output
See the description of the GPFSEL registers, starting with "GPIO Function Select Registers (GPFSELn)"
There you see that for every port/pin there are THREE bits to set, "001" means this port is an output.
They show FSEL9 and FSEL19 as examples for pin 9 and pin 19, but it is the same for all other ports.

Check the code in tog1.c line 75:
Code: Select all
    /* Set GPIO 17/1 as an output pin */
    GPFSEL0 &= ~(7 << 3); // Mask out bits 5-3 of GPFSEL0 (i.e. force to zero)
    GPFSEL0 |= (1 << 3);  // Set bits 5-3 of GPFSEL0 to binary '001'

First line clears bits 3, 4 and 5 of GPFSEL0: -> Check the pdf -> the FSEL1 bits are clean now!
Second line sets the three bits to 001: -> Check the pdf -> 001 = GPIO Pin 1 is now an output!
Setting is done by shifting the value to the left by a number (3 in this example)
( Visualise this for yourself by putting the 001 in bits 0,1 and 2, and then shift them three times to the left. You will see that the bits are now on 3, 4 and 5.)

If you want to change the portnumber, change this code.
- Use the correct GPFSELn register, which is dependant on the port number.
example: port 5 will be in GPFSEL0, port 17 would be in GPFSEL1
- Use the correct shift value. (Now it is 3, to shift to bit 3, 4 and 5)
example: port 5 will need a shift of 15, check GPFSEL0 in the pdf
example: port 17 will need a shift of 21, check GPFSEL1 in the pdf

So for port 5:
Code: Select all
   /* Set GPIO 5 as an output pin */
    GPFSEL0 &= ~(7 << 15); // Mask out bits 17-15 of GPFSEL0 (i.e. force to zero)
    GPFSEL0 |= (1 << 15);  // Set bits 17-15 of GPFSEL0 to binary '001'


Or for port 17:
Code: Select all
   /* Set GPIO 17 as an output pin */
    GPFSEL1 &= ~(7 << 21); // Mask out bits 23-21 of GPFSEL1 (i.e. force to zero)
    GPFSEL1 |= (1 << 21);  // Set bits 23-21 of GPFSEL1 to binary '001'


You have set your port to be an output. Good.. Now writing to the port

2.Set the correct port to value 0 or 1.
check the code in tog1.c line 79:
Code: Select all
    if(gpio_state == 0)
        GPCLR0 = BIT_1;
    else if(gpio_state == 1)
        GPSET0 = BIT_1;


GPCLR0 and GPSET0 are registers, see page 95.
To set a port, write a 1 to the correct bit in GPSET0.
To clear a bit write a 1 to the correct bit in GPCLR0.
Yes, you write a 1 to get a 0 on the port. Weird eh.

BIT_1 is a mask defined in line 37.
example for bit 5 and 17:
Code: Select all
#define BIT_5 (1 << 5)
#define BIT_17 (1 << 17)


Change the BIT_1 to the correct value

example for port 5:
Code: Select all
    if(gpio_state == 0)
        GPCLR0 = BIT_5;
    else if(gpio_state == 1)
        GPSET0 = BIT_5;


example for port 17:
Code: Select all
    if(gpio_state == 0)
        GPCLR0 = BIT_17;
    else if(gpio_state == 1)
        GPSET0 = BIT_17;


Those two are the things to change. nothing else.
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by enixidfrag » Sun Aug 05, 2012 4:45 pm
Ok so I got it running locally. But the server doesnt seem to be broadcasting to the internet. I have enabled port forwarding on my router for the Pi for port 80 as well as port 1337 (which I added to /etc/apache2/port.conf) but it's giving me an error message of webpage not available. Any suggestions
Posts: 8
Joined: Mon Jul 16, 2012 11:24 pm
by TonAu » Sun Aug 05, 2012 5:29 pm
By local you mean on the local network right? From your PC connected to the same network as your Pi you can get a connection?

Check the forwarding table in the router again. Check the IP address of the Pi again.

What happened to me is this:
The router was forwarding ok, but when I entered by external IP address in the browser (So the IP address that your router has to the world, the IP adress that you want the Pi to be reachable at) the browser gave a not reachable. It seemed that my Internet Service Provider/Router could not resolve that back to my outside address.
Did you try to reach the Pi from outside your own local network? From a friend, or maybe from your moblie (Then not in Wifi ofcourse)?
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by enixidfrag » Sun Aug 05, 2012 6:01 pm
Ok i fixed it problem is you can't have a port higher then 1024. However for some reason the wordpress admin panel is working fine but wordpress itself won't show? Now I'm having problems with BIND9 also lol /etc/apt/sources.list doesnt have what it needs for repositories i guess so it can compile and install.

Nvm the BIND9 problem as tutorial looks to be outdated as it seems to be installing fine with a simple
"sudo apt-get install bind9"
Posts: 8
Joined: Mon Jul 16, 2012 11:24 pm
by enixidfrag » Sun Aug 05, 2012 8:31 pm
Ok so possibly stupid question but how do I use my domain name from go daddy on my server?
Posts: 8
Joined: Mon Jul 16, 2012 11:24 pm
by TonAu » Sun Aug 05, 2012 8:46 pm
Well, do not know go daddy, but I assume you have a domain name registered there.
So you would be able to link an IP address to your domain name at daddies somewhere.

There you enter the external IP address of your router. Then it should work.

But if there are any go daddy specific matters, then you are on your own
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by enixidfrag » Sun Aug 05, 2012 10:11 pm
No can't find it in there. Gonna try easydns.com

Anyone else not able to share on ports higher then 1000 range? Also how do you make it so you don't to use port in web address?
Posts: 8
Joined: Mon Jul 16, 2012 11:24 pm
by TonAu » Mon Aug 06, 2012 10:54 am
When you do not want to put a port in the URL you can only use the default port 80 .
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am
by texy » Mon Aug 06, 2012 6:52 pm
Hi,
I,m getting this error :

Code: Select all
root@raspberrypi:~# sudo service apache2 restart
[....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
. ok


It could be due to not setting step 2 correctly, as it is not altogether clear to me. Is this right :

Code: Select all
send host-name "raspberryPi";
send host-name = gethostname();

Note I have restarted the pi after editing the dhclient.conf file.
This is with the raspbian wheezy image, perhaps this procedure is not compatble with this distro ?

Texy
"2.8inch TFT LCD + Touch screen" add-on boards for sale here :
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=93&t=65566
50p goes to the Foundation ;-)
Moderator
Posts: 2202
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England
by TonAu » Mon Aug 06, 2012 7:41 pm
Well, it is not really an error, the webserver is running.
I have that warning also, but all works fine for me.

When you have configured samba, your machine is reachable under http:\\raspnameyougave, even though apache complains.
Posts: 25
Joined: Sat Jul 21, 2012 11:23 am