All Stories

Friday, 28 June 2013

Introduction

I was listening to the Linux Action Show series 27 episode 6 today and there was a short section about a website called Instant Server

Basically you visit the site, click create and you get access to a fully fledged Ubuntu 64-bit server. 

There is of course a catch. You get 35 minutes to use this server and basically it is headless which means that any immediate uses I could think of were negated.

Try it out

To try out Instant Server go to the site by clicking on the link and click the "Get a free server" link.






















You are given a username and password and a link to open a terminal.

Click the open terminal link and you are in.






The idea of the instant server seems like a fun one and then the obvious thought goes through your head. (well it did mine).

What can you use this for? It certainly has a good download speed but that isn't much use because it downloads to a server that will disappear within 35 minutes.

Then I thought about viewing webpages that are blocked by default at my place of work. The problem of course is the lack of X so we are now looking for a browser that works without X.


Installed by default is a text based browser called W3M and as you can see by the picture to the left it works.

This means that I can finally read those articles on LXER that get blocked at work and that I'm too tired to read at the end of the day.

This is all well and good of course if the article is mainly text based. Images provide other issues.




Another option is to download movies from youtube and maybe play them back in MPlayer. I haven't tried this yet but fully intend to. 

I like the idea of internal server but I cannot think of enough uses and this is where I am after your help. What can you do with a headless server in 35 minutes?

What can you do with a headless server in 35 minutes?

Introduction

I was listening to the Linux Action Show series 27 episode 6 today and there was a short section about a website called Instant Server

Basically you visit the site, click create and you get access to a fully fledged Ubuntu 64-bit server. 

There is of course a catch. You get 35 minutes to use this server and basically it is headless which means that any immediate uses I could think of were negated.

Try it out

To try out Instant Server go to the site by clicking on the link and click the "Get a free server" link.






















You are given a username and password and a link to open a terminal.

Click the open terminal link and you are in.






The idea of the instant server seems like a fun one and then the obvious thought goes through your head. (well it did mine).

What can you use this for? It certainly has a good download speed but that isn't much use because it downloads to a server that will disappear within 35 minutes.

Then I thought about viewing webpages that are blocked by default at my place of work. The problem of course is the lack of X so we are now looking for a browser that works without X.


Installed by default is a text based browser called W3M and as you can see by the picture to the left it works.

This means that I can finally read those articles on LXER that get blocked at work and that I'm too tired to read at the end of the day.

This is all well and good of course if the article is mainly text based. Images provide other issues.




Another option is to download movies from youtube and maybe play them back in MPlayer. I haven't tried this yet but fully intend to. 

I like the idea of internal server but I cannot think of enough uses and this is where I am after your help. What can you do with a headless server in 35 minutes?

Posted at 00:34 |  by Gary Newell

8 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

Tuesday, 25 June 2013

The first article on my new blog (other than a brief welcome message) is a review of Ubuntu 13.04 aimed at people who have never used Ubuntu before.

To view the article visit http://myubuntublog.com/?p=17.




A Whistlestop Tour Of Ubuntu 13.04

The first article on my new blog (other than a brief welcome message) is a review of Ubuntu 13.04 aimed at people who have never used Ubuntu before.

To view the article visit http://myubuntublog.com/?p=17.




Posted at 23:54 |  by Gary Newell

0 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

I have used 33 different Linux distributions in the past year but whilst writing an updated review for Ubuntu 13.04 I realised that I am so happy with the new version I don't want to distrohop anymore.

I have decided that Unity is not the 2 headed beast that so many people say that it is. I find it so easy to navigate that I don't feel the need to customise my distribution to within an inch of its life.

With this in mind I have decided to change focus and write solely about Ubuntu. Now I could not do that on this blog as this blog is about Linux in general so I have created a brand new blog called "My Ubuntu Blog" (www.myubuntublog.com).

If you like my style of writing and you are interested in Ubuntu then feel free to come along and subscribe to the new blog.

The Everyday Linux User blog will remain in place but will be less about reviews and more about how to guides, news, comment and other interesting Linux articles that I find along the way.




My Ubuntu Blog

I have used 33 different Linux distributions in the past year but whilst writing an updated review for Ubuntu 13.04 I realised that I am so happy with the new version I don't want to distrohop anymore.

I have decided that Unity is not the 2 headed beast that so many people say that it is. I find it so easy to navigate that I don't feel the need to customise my distribution to within an inch of its life.

With this in mind I have decided to change focus and write solely about Ubuntu. Now I could not do that on this blog as this blog is about Linux in general so I have created a brand new blog called "My Ubuntu Blog" (www.myubuntublog.com).

If you like my style of writing and you are interested in Ubuntu then feel free to come along and subscribe to the new blog.

The Everyday Linux User blog will remain in place but will be less about reviews and more about how to guides, news, comment and other interesting Linux articles that I find along the way.




Posted at 23:49 |  by Gary Newell

0 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

Sunday, 16 June 2013

I thought I would let regular readers know that I haven't stopped writing but I am taking a break for a month or so due to work and family commitments.

If I get a chance to post during the next 6 weeks then I will but I will ramp back up nearer the autumn.


Taking a break

I thought I would let regular readers know that I haven't stopped writing but I am taking a break for a month or so due to work and family commitments.

If I get a chance to post during the next 6 weeks then I will but I will ramp back up nearer the autumn.


Posted at 21:03 |  by Gary Newell

0 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

Wednesday, 5 June 2013

Introduction

Yesterday I wrote an article showing how to set up the Raspberry PI as a personal web server

The concept of setting up the personal web server on the Raspberry PI really was for a hobby project and shouldn't really be used for hosting an external website. There are various reasons for this such as security, the power of the Raspberry PI, bandwidth and the fact that your external IP address will change at regular intervals.

This article goes some way to addressing some of the things you will need to do to connect to the website on your Raspberry PI from the outside world.

This is a proof of concept and just ideas on paper (or screen) and should not be seen as a gospel guide.

I will warn you now that I have never been that good with the networking side of things so I will try and explain as best I can. I may or may not be wrong in places and I am relying on people to correct me in the comments section.

Get your External IP address

There are basically 2 IP addresses that are important. There is the internal IP address which you can get by running IFCONFIG in a terminal.

When you connect to the internet you will actually be using an external IP address. 

I followed this guide (http://www.if-not-true-then-false.com/2010/linux-get-ip-address/) to get an external IP address.

I installed lynx first by running the following in the command line:
sudo apt-get install lynx
Then I ran the following command to get the external IP address.
lynx --dump http://ipecho.net/plain
Another way to get your external IP address is to log onto http://www.whatismyip.com/ but I will explain later why I bothered to install lynx.



Port Forwarding

Now this is the part that I can't really explain in much detail because it depends on the ISP and the router that you are using as to how it is done.

I am using 3 Mobile Broadband and to forward ports using this service you have to open a web browser and navigate to http://192.168.1.1.

This takes you to the home page of the router. There is a login section where you can then access more intricate settings for the router.

On 3 Mobile Broadband there is a settings tab and then under the security heading there is a section called virtual servers.

This is where the port forwarding takes place.

All I had to do was add a new row into the grid and enter the following details:

  • name
  • wan port
  • lan ip address
  • lan port
  • protocol
  • status
The name is just a description so that I can remember what the purpose of the entry is in the list. The wan port is the port from the outside world and so for the web server I entered 80 and for ssh I set this to 22
The lan ip address is the address to the Raspberry PI (run IFCONFIG to get this).
The lan port is the port to forward to on the Raspberry PI. For a web page I set this to 80. For ssh I set this to 22.
The protocol is either TCP, UDP or ALL.
The status can be set to on or off and obviously I set this to on.

Pressing Apply applied the changes.

Testing it out



















It is not possible to test this on the same network that the Raspberry PI is on. So if you are using the same broadband connection as the PI then you can't test connecting from the internet to the Raspberry PI as you would essentially be accessing the Raspberry PI from inside the network.

You will therefore need to test it from something not connected using the same network (broadband connection). If you have a 3G smart phone then you can use the browser on the phone to try to connect to your external ip address, alternatively pop round to the local library or pop to your nearest electronics store and buy a cheap 3G dongle. 

If it worked correctly then you will see the web page appear.

Troubleshooting

What happens if you cannot connect to the Raspberry PI?

First of all it is a good idea to see which ports are available from the outside world.

There are a number of sites that provide such a service. One of these services is available at http://www.yougetsignal.com/tools/open-ports/.
























You can enter the external IP address and ports to check and you will be told whether they are visible from the outside world. 

If the port is not open or visible then you have set up the port forwarding incorrectly.

Static IP address

To prevent everyone setting themselves up as web hosts, ISPs give each of their customers a dynamic IP address.

This means that the external IP address you will use today to connect to your site will be different tomorrow or even in just a few hours time.

If you are determined to use your Raspberry PI as a web server (not recommended) then there is a service at http://dyn.com/dns/ which enables you to set up an address that will remain static so you can always access the websites and ssh on your Raspberry PI.

Remote access to the Raspberry PI

If however you just want to be able to access your Raspberry PI from say your work then you won't want to pay money to access your Raspberry PI.

I use the following method to continuously be able to access my Raspberry PI when I need to.

First of all I installed SSMTP by following this guide. (http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/).

To install SSMTP I ran the following command:
sudo apt-get install ssmtp
Next I edited the ssmtp.conf file by running the following command:
sudo nano /etc/ssmtp/ssmtp.conf
I then added the following to the end of the file:

root=postmaster 
mailhub=smtp.gmail.com:587
hostname=raspberrypiAuthUser=myemailaddressAuthPass=myemailpasswordUseSTARTTLS=YES
I pressed CTRL O to save the file and CTRL X to exit nano.

Next  I edited the revaliases file by typing the following command.
sudo nano /etc/ssmtp/revaliases
Within the file I added the following line

pi:pi@everydaylinuxuser.com:smtp.gmail.com:587

I then saved the file by pressing CTRL O and exited the file by pressing CTRL and X

Finally I set the permissions to 774 by running the following command:
sudo chmod 774 /etc/ssmtp/ssmtp.conf
All of this basically enables me to send an email.

To send an email all I have to do is run a command and output it to the mail command. For example:
lynx --dump http://ipecho.net/plain | mail -s "Your PI IP" me@myemailaddress.com
This emails my IP address to my email address

Obviously this only does it once and so it would be better if it sent me an email at regular intervals so that I can see if there has been a change.

To do this I added the above command to a script called sendmemyIP.sh. I opened the script by typing the following:
sudo nano sendmemyIP.sh
I then copied the lynx command into the script and pressed CTRL O to save and CTRL X to exit nano.

To get the script to run regularly I added it as a cron job by copying sendmemyIP.sh to /etc/cron.hourly.
sudo cp sendmemyIP.sh /etc/cron.hourly/sendmemyIP.sh
Now when my Raspberry PI is turned on it will send the IP address to my email inbox once an hour.

I can then use this IP address within putty or ssh to access my Raspberry PI from anywhere.

Summary

This was all done as a proof of concept and I'm looking to the community to tell me if there are any glaring no-nos with the approach I have taken.

It certainly works for me and hopefully it will help some other people out there looking to try the same thing.

Thankyou for reading.


Connecting to the Raspberry PI from the outside world

Introduction

Yesterday I wrote an article showing how to set up the Raspberry PI as a personal web server

The concept of setting up the personal web server on the Raspberry PI really was for a hobby project and shouldn't really be used for hosting an external website. There are various reasons for this such as security, the power of the Raspberry PI, bandwidth and the fact that your external IP address will change at regular intervals.

This article goes some way to addressing some of the things you will need to do to connect to the website on your Raspberry PI from the outside world.

This is a proof of concept and just ideas on paper (or screen) and should not be seen as a gospel guide.

I will warn you now that I have never been that good with the networking side of things so I will try and explain as best I can. I may or may not be wrong in places and I am relying on people to correct me in the comments section.

Get your External IP address

There are basically 2 IP addresses that are important. There is the internal IP address which you can get by running IFCONFIG in a terminal.

When you connect to the internet you will actually be using an external IP address. 

I followed this guide (http://www.if-not-true-then-false.com/2010/linux-get-ip-address/) to get an external IP address.

I installed lynx first by running the following in the command line:
sudo apt-get install lynx
Then I ran the following command to get the external IP address.
lynx --dump http://ipecho.net/plain
Another way to get your external IP address is to log onto http://www.whatismyip.com/ but I will explain later why I bothered to install lynx.



Port Forwarding

Now this is the part that I can't really explain in much detail because it depends on the ISP and the router that you are using as to how it is done.

I am using 3 Mobile Broadband and to forward ports using this service you have to open a web browser and navigate to http://192.168.1.1.

This takes you to the home page of the router. There is a login section where you can then access more intricate settings for the router.

On 3 Mobile Broadband there is a settings tab and then under the security heading there is a section called virtual servers.

This is where the port forwarding takes place.

All I had to do was add a new row into the grid and enter the following details:

  • name
  • wan port
  • lan ip address
  • lan port
  • protocol
  • status
The name is just a description so that I can remember what the purpose of the entry is in the list. The wan port is the port from the outside world and so for the web server I entered 80 and for ssh I set this to 22
The lan ip address is the address to the Raspberry PI (run IFCONFIG to get this).
The lan port is the port to forward to on the Raspberry PI. For a web page I set this to 80. For ssh I set this to 22.
The protocol is either TCP, UDP or ALL.
The status can be set to on or off and obviously I set this to on.

Pressing Apply applied the changes.

Testing it out



















It is not possible to test this on the same network that the Raspberry PI is on. So if you are using the same broadband connection as the PI then you can't test connecting from the internet to the Raspberry PI as you would essentially be accessing the Raspberry PI from inside the network.

You will therefore need to test it from something not connected using the same network (broadband connection). If you have a 3G smart phone then you can use the browser on the phone to try to connect to your external ip address, alternatively pop round to the local library or pop to your nearest electronics store and buy a cheap 3G dongle. 

If it worked correctly then you will see the web page appear.

Troubleshooting

What happens if you cannot connect to the Raspberry PI?

First of all it is a good idea to see which ports are available from the outside world.

There are a number of sites that provide such a service. One of these services is available at http://www.yougetsignal.com/tools/open-ports/.
























You can enter the external IP address and ports to check and you will be told whether they are visible from the outside world. 

If the port is not open or visible then you have set up the port forwarding incorrectly.

Static IP address

To prevent everyone setting themselves up as web hosts, ISPs give each of their customers a dynamic IP address.

This means that the external IP address you will use today to connect to your site will be different tomorrow or even in just a few hours time.

If you are determined to use your Raspberry PI as a web server (not recommended) then there is a service at http://dyn.com/dns/ which enables you to set up an address that will remain static so you can always access the websites and ssh on your Raspberry PI.

Remote access to the Raspberry PI

If however you just want to be able to access your Raspberry PI from say your work then you won't want to pay money to access your Raspberry PI.

I use the following method to continuously be able to access my Raspberry PI when I need to.

First of all I installed SSMTP by following this guide. (http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/).

To install SSMTP I ran the following command:
sudo apt-get install ssmtp
Next I edited the ssmtp.conf file by running the following command:
sudo nano /etc/ssmtp/ssmtp.conf
I then added the following to the end of the file:

root=postmaster 
mailhub=smtp.gmail.com:587
hostname=raspberrypiAuthUser=myemailaddressAuthPass=myemailpasswordUseSTARTTLS=YES
I pressed CTRL O to save the file and CTRL X to exit nano.

Next  I edited the revaliases file by typing the following command.
sudo nano /etc/ssmtp/revaliases
Within the file I added the following line

pi:pi@everydaylinuxuser.com:smtp.gmail.com:587

I then saved the file by pressing CTRL O and exited the file by pressing CTRL and X

Finally I set the permissions to 774 by running the following command:
sudo chmod 774 /etc/ssmtp/ssmtp.conf
All of this basically enables me to send an email.

To send an email all I have to do is run a command and output it to the mail command. For example:
lynx --dump http://ipecho.net/plain | mail -s "Your PI IP" me@myemailaddress.com
This emails my IP address to my email address

Obviously this only does it once and so it would be better if it sent me an email at regular intervals so that I can see if there has been a change.

To do this I added the above command to a script called sendmemyIP.sh. I opened the script by typing the following:
sudo nano sendmemyIP.sh
I then copied the lynx command into the script and pressed CTRL O to save and CTRL X to exit nano.

To get the script to run regularly I added it as a cron job by copying sendmemyIP.sh to /etc/cron.hourly.
sudo cp sendmemyIP.sh /etc/cron.hourly/sendmemyIP.sh
Now when my Raspberry PI is turned on it will send the IP address to my email inbox once an hour.

I can then use this IP address within putty or ssh to access my Raspberry PI from anywhere.

Summary

This was all done as a proof of concept and I'm looking to the community to tell me if there are any glaring no-nos with the approach I have taken.

It certainly works for me and hopefully it will help some other people out there looking to try the same thing.

Thankyou for reading.


Posted at 00:08 |  by Gary Newell

3 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

Monday, 3 June 2013

Introduction

This week has been an awful week. I have basically had very limited access to the internet and so this has put me behind on the schedule that I had set for May.

I have therefore decided this week to finally type up the notes I had taken when setting up the Raspberry PI as a personal web server.

Why set up a Web Server on the Raspberry PI?

There are a few reasons why you might set up your Raspberry PI to run as a web server.

If you are a student learning to program then you might find it useful to run the Raspberry PI as a web server so that you can practice your PHP scripting or PERL scripting. PHP is good as it is a modern OO language that incorporates a lot of the principles of other programming languages

You can learn common techniques with PHP such as test driven development. There are also good coding frameworks available such as Codeigniter which will help you learn MVC. Skills learned in PHP can easily be transposed to other languages including C# and Java.

Other more hobbyist programmers might like a web server to run something like Joomla to create a home intranet site.

People who design Wordpress templates might like a personal web server to test out new templates. By using the Raspberry PI as the web server the designer can use other computers to make sure the layout looks good in Internet Explorer, Chrome and Firefox.

Assumptions

This guide assumes you are using the default Raspbian Wheezy operating system.

The web server that is to be used is Lighttpd.

PHP will be installed as the scripting language.

MySQL will be installed as the database server.

Get your IP Address

If you are working directly on the Raspberry PI then you can skip this part but if you are accessing via SSH obtain the IP Address of the Raspberry PI by typing the following into a terminal window on the Raspberry PI.

ifconfig
This will return an IP address in the form of 192.168.1.x where x is the 4th number. (For example 30).

If you follow this guide direct from the PI then you can get away with using localhost instead of the IP address when specified later on in the guide and you can skip the SSH step below.

SSH


If you plan to SSH onto the Raspberry PI from within Windows run Putty.exe (http://www.putty.org/) and type in the IP address into the Host Name box. Now click "Open".

If you plan to SSH onto the Raspberry PI from within Linux open a terminal window and type SSH 192.168.1.x (where x is the last number).

Whether you are running from within Windows or Linux you will be asked for the username and password. You should enter "pi" as the user and the password you set up for the "pi" user when you installed Raspbian.

You should now be logged in via SSH.

Update your repositories

First of all run an apt-get update to make sure everything you need is available to download.

sudo apt-get update

Installing Lighttpd



There are quite a few guides on the internet for showing how to set up a web server. For the Raspberry PI I chose to install Lighttpd as it is light in nature and won't use up too much of the Raspberry PI's resources.

To install Lighttpd run the following command
sudo apt-get install lighttpd

To test whether the web server is installed correctly type the following into the web browser address bar:

http://192.168.1.x
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost
You should see a placeholder page as shown above.

Installing PHP

To install PHP run the following command:

sudo apt-get install php5-cgi























Now you need to add a line to the php.ini file. To do this there is a file called php.ini in /etc/php5/cgi.

Type the following:
sudo nano /etc/php5/cgi/php.ini
Navigate to the bottom of the file and add the following line.
cgi.fix_pathinfo = 1
To save the file press CTRL and O on the keyboard and to exit nano press CTRL and X.

Finally to get fast CGI working type the following onto the command line:
sudo lighty-enable-mod fastcgi
(PLEASE NOTE THIS WAS MISSING FROM THE ORIGINAL VERSION) 

Now type the following:

sudo lighty-enable-mod fastcgi-php 
Now the web server needs to be restarted.
sudo /etc/init.d/lighttpd restart

Create a test PHP script

To test that PHP is installed correctly type the following into the terminal window:
sudo nano /var/www/phpinfo.php
Now within nano enter the following script:
<?php    phpinfo();?>
Press CTRL and O to save the file and CTRL and X to exit nano.


Within a web browser type the following into the address bar:

http://192.168.1.x/phpinfo.php
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost/phpinfo.php

Install MySQL

There are three applications that will be installed for MySQL:


  • MySQL-Server
  • MySQL-Client
  • PHPMyAdmin


MySQL-Server is the actual database server.
MySQL-Client enables you to interact with the server from the command line.
PHPMyAdmin enables you to interact with the server from within a web browser.


 To install all three applications at once type the following into the terminal window:
sudo apt-get install mysql-server mysql-client phpmyadmin

























During the install you will be asked to enter a password for the root user. Do not confuse this with the root user within Linux. This is the root password for the database server. Enter a strong password. Repeat the password when asked to do so.



During the installation of PHPMyAdmin you will be asked which web server is installed. Choose lighttpd.























A message will appear asking whether you want to create a dummy database. As the message states, if you know what you are going to be using the database server for or a database is already configured then you can answer no but if you are just experimenting then you can answer yes.

I recommend answering yes to this. It doesn't do any harm.























You will now be asked to enter the root password and repeat it. Enter the root password you created earlier. (remember this is the database root password, not the linux root password).

When the install has finished restart the server by typing the following into the terminal:

sudo /etc/init.d/lighttpd restart

To test that the database server has been installed correctly open a browser window type the following into the address bar:


http://192.168.1.x/phpmyadmin
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost/phpmyadmin



Enter the username and password to log in. 

Summary

This tutorial has shown how to set up the basic web server with PHP and MySQL

You might now want to try installing Wordpress, Joomla, Codeigniter and Blueprint.

I will be following up this article with details of how to install the aforementioned items later this week. I will also show you how to access the web pages externally and how to set up a host name to replace the IP address.

If you have any problems using this guide or you have tips for other users feel free to add them to the comments section.

Thankyou for reading.


Setting up a personal web server on the Raspberry PI

Introduction

This week has been an awful week. I have basically had very limited access to the internet and so this has put me behind on the schedule that I had set for May.

I have therefore decided this week to finally type up the notes I had taken when setting up the Raspberry PI as a personal web server.

Why set up a Web Server on the Raspberry PI?

There are a few reasons why you might set up your Raspberry PI to run as a web server.

If you are a student learning to program then you might find it useful to run the Raspberry PI as a web server so that you can practice your PHP scripting or PERL scripting. PHP is good as it is a modern OO language that incorporates a lot of the principles of other programming languages

You can learn common techniques with PHP such as test driven development. There are also good coding frameworks available such as Codeigniter which will help you learn MVC. Skills learned in PHP can easily be transposed to other languages including C# and Java.

Other more hobbyist programmers might like a web server to run something like Joomla to create a home intranet site.

People who design Wordpress templates might like a personal web server to test out new templates. By using the Raspberry PI as the web server the designer can use other computers to make sure the layout looks good in Internet Explorer, Chrome and Firefox.

Assumptions

This guide assumes you are using the default Raspbian Wheezy operating system.

The web server that is to be used is Lighttpd.

PHP will be installed as the scripting language.

MySQL will be installed as the database server.

Get your IP Address

If you are working directly on the Raspberry PI then you can skip this part but if you are accessing via SSH obtain the IP Address of the Raspberry PI by typing the following into a terminal window on the Raspberry PI.

ifconfig
This will return an IP address in the form of 192.168.1.x where x is the 4th number. (For example 30).

If you follow this guide direct from the PI then you can get away with using localhost instead of the IP address when specified later on in the guide and you can skip the SSH step below.

SSH


If you plan to SSH onto the Raspberry PI from within Windows run Putty.exe (http://www.putty.org/) and type in the IP address into the Host Name box. Now click "Open".

If you plan to SSH onto the Raspberry PI from within Linux open a terminal window and type SSH 192.168.1.x (where x is the last number).

Whether you are running from within Windows or Linux you will be asked for the username and password. You should enter "pi" as the user and the password you set up for the "pi" user when you installed Raspbian.

You should now be logged in via SSH.

Update your repositories

First of all run an apt-get update to make sure everything you need is available to download.

sudo apt-get update

Installing Lighttpd



There are quite a few guides on the internet for showing how to set up a web server. For the Raspberry PI I chose to install Lighttpd as it is light in nature and won't use up too much of the Raspberry PI's resources.

To install Lighttpd run the following command
sudo apt-get install lighttpd

To test whether the web server is installed correctly type the following into the web browser address bar:

http://192.168.1.x
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost
You should see a placeholder page as shown above.

Installing PHP

To install PHP run the following command:

sudo apt-get install php5-cgi























Now you need to add a line to the php.ini file. To do this there is a file called php.ini in /etc/php5/cgi.

Type the following:
sudo nano /etc/php5/cgi/php.ini
Navigate to the bottom of the file and add the following line.
cgi.fix_pathinfo = 1
To save the file press CTRL and O on the keyboard and to exit nano press CTRL and X.

Finally to get fast CGI working type the following onto the command line:
sudo lighty-enable-mod fastcgi
(PLEASE NOTE THIS WAS MISSING FROM THE ORIGINAL VERSION) 

Now type the following:

sudo lighty-enable-mod fastcgi-php 
Now the web server needs to be restarted.
sudo /etc/init.d/lighttpd restart

Create a test PHP script

To test that PHP is installed correctly type the following into the terminal window:
sudo nano /var/www/phpinfo.php
Now within nano enter the following script:
<?php    phpinfo();?>
Press CTRL and O to save the file and CTRL and X to exit nano.


Within a web browser type the following into the address bar:

http://192.168.1.x/phpinfo.php
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost/phpinfo.php

Install MySQL

There are three applications that will be installed for MySQL:


  • MySQL-Server
  • MySQL-Client
  • PHPMyAdmin


MySQL-Server is the actual database server.
MySQL-Client enables you to interact with the server from the command line.
PHPMyAdmin enables you to interact with the server from within a web browser.


 To install all three applications at once type the following into the terminal window:
sudo apt-get install mysql-server mysql-client phpmyadmin

























During the install you will be asked to enter a password for the root user. Do not confuse this with the root user within Linux. This is the root password for the database server. Enter a strong password. Repeat the password when asked to do so.



During the installation of PHPMyAdmin you will be asked which web server is installed. Choose lighttpd.























A message will appear asking whether you want to create a dummy database. As the message states, if you know what you are going to be using the database server for or a database is already configured then you can answer no but if you are just experimenting then you can answer yes.

I recommend answering yes to this. It doesn't do any harm.























You will now be asked to enter the root password and repeat it. Enter the root password you created earlier. (remember this is the database root password, not the linux root password).

When the install has finished restart the server by typing the following into the terminal:

sudo /etc/init.d/lighttpd restart

To test that the database server has been installed correctly open a browser window type the following into the address bar:


http://192.168.1.x/phpmyadmin
Replace x with the last number of your IP address. If you are running directly on the Raspberry PI then you can just enter the following:
http://localhost/phpmyadmin



Enter the username and password to log in. 

Summary

This tutorial has shown how to set up the basic web server with PHP and MySQL

You might now want to try installing Wordpress, Joomla, Codeigniter and Blueprint.

I will be following up this article with details of how to install the aforementioned items later this week. I will also show you how to access the web pages externally and how to set up a host name to replace the IP address.

If you have any problems using this guide or you have tips for other users feel free to add them to the comments section.

Thankyou for reading.


Posted at 23:26 |  by Gary Newell

27 comments:

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

    Popular Posts

    Subscribe

    Enter your email address:

    Delivered by FeedBurner

    Popular This Month

    What are other people buying?

    Lubuntu
    PCLinuxOS
    Linux Mint
    Manjaro
    Knoppix

back to top