Start using Fuel PHP today


The last few days I have been busy looking at the Fuel PHP framework. And it’s AWESOME. That’s not a great description, its not even very objective, but none the less it is true (you will have to take my word for it now). The framework can be found at fuelphp.com.

Today I am going to give a quick guide for installing and running Fuel PHP on a linux machine and some extra cool tricks to make the setup easier. First what things do you need, assuming that you have a fresh linux install.

  • apache webserver
  • php 5.3 (needs to be at least 5.3)
  • php cli (command line interface)
  • mysql database server
  • command line editor vi or vim (not totally necessary but i will assume that you have one as I believe command line file editing to be the easiest option)
  • wget or curl (fuel documentation uses curl but either could be used)

I will also assume that you have root access and that you are on a home computer using localhost for your domain. Production environments require more careful setup and I will address those issues in a completely different post.

Lets Go

1. install all the necessary components

sudo apt-get update
sudo apt-get install php5 php5-cli apache2 mysql-server phpmyadmin curl vim git-core

2. install the fuel PHP oil installer. (that sounds strange)

curl get.fuelphp.com/oil | sh

3. change into the directory that you want to build you fuel application in and run the fuel PHP oil create script. replace {user} with your username and {app name} with the name you want to give your application. it doesn’t matter what the name is as it wont get used in the website URI

cd /home/{user}/Public/
oil create {app name}

4. Now it that’s as far as the basic section of the documentation on the fuelphp.com documentation website. However you cannot access the app in the browser yet. Before you can do that there are a few steps that you must take. We have to set up the apache virtual host. This greatly varies on you operating system, but for simplicity I will cover just Ubuntu, and will cover different OS’s later. We need to alter the virtual host so that it follows symbolic links and knows what the root directory of the website is. Because the fuel index.php file is in the public folder in the actual top directory we will include the public directory in the website root directory.

sudo vim /etc/apache2/sites-enabled/000-default

Now make the file look like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/{user}/Public/{app name}/public
        <Directory />
                Options FollowSymLinks
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        <Directory /home/{user}/Public/{app name}/public>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

Restart apache to apply the configuration changes

sudo /etc/init.d/apache2 restart

5. If everything worked you should now be able to go to http://localhost/ and the fuel app page should be visible. It looks a little bit like the codeigniter welcome page. (most of the developers of fuel have or still do contribute to codeigniter).

Conclusion

Hopefully this is guide is a relatively straight forward explanation of how to set up fuel on a new development environment. Any questions or comments are appreciated. I’m sure I made a mistake somewhere in there or perhaps it just didn’t work on your computer. I would also love to get some suggestions on what you would like to see next.

Advertisements

Working For a Client – Building a Computer System


At one point in time, those people with a rough to well formed knowledge of a computer have been asked to help out a family member or friend with an ‘silicon’ based issue. It is usually a case of having clicked on a suspect link or open a attachment from a phishing email and more often than not there is either a quick fix or no fix(other than a clean OS install). Sometimes though, very occasionally, you might get asked to setup an entire home computer system.

This is what I intend on being a series of posts, not so much on the nitty gritties of setting up individual components of a system, but creating the entire workable system. At the conclusion of the series I will be releasing my backup program written for the system in a form that everyone can use.

A point that should be made is that this is the first time I have done this is at a non personal level. The resources that I have used range from manuals to forums and wiki’s to websites and is by no means a complete body of knowledge, and it should never be expected to be complete. The point is that what I have done is not necessarily the quickest, most efficient way of doing things (although it might be). Hopefully if nothing else it leads to a thorough discussion and a greater understanding if computer systems as a whole.

Project Outline

This project is centered around a small photography hobby as well as general data storage. There where a number of considerations when taking into account the clients needs.

  1. How much data storage would be needed in the long and short term.
  2. How often would files need to be moved around and accessed
  3. What peripherals would be used now and in the future and what would the level of difficulty be to add them at creation date or later.
  4. What would the future needs of the client be in 1 year, 5 years, 10 years time

Concern 1

The first concern is how much data storage is needed. This usually isn’t the first question I would ask when discussing the needs of a client, however, I soon found that depending on the size of the system the physical needs vary greatly. If only a small volume of storage is needed then a centralized server may not be needed. If a large system is needed for working with large files then working over a network is preferable to a adding a USB HDD to a pre-existing computer.

The client is a hobby photographer and works with often large photo’s (>20 Mb) and in large collections. They need to be able to have fast access to the images as well know that they can not lose any data by accident. I calculated from the information that I was able to gather, that a file space of approximately 4Tb (Terabytes) would be sufficient.

Concern 2

The second concern, following directly from the first, is how often will the files need to be accessed and used. This is relatively straight forward, In this case, the files need to be both backed up and stored on a local server and will be accessed many times a day. This helps us determine the way that we will arrange the HDD arrays and define the backup scripts.

Concern 3

The third concern is what peripherals will be needed now and in the future and hard difficult they will be to setup. The first and foremost is the camera’s themselves, then any portable devices such as tablet PC’s and smart phones. There is also guest computers for collaborative work and visitors, A potential Home theater PC and lastly printers.

Most of these are relatively straight forward. Most just require the setup and regular rotation of a password, The camera’s come with software and The media based computer can be built on a UPnP system. The only difficult setup would be the network computers.

Concern 4

The forth, final and most important concern is, what are the FUTURE needs. This is a difficult question, and one that i was not able to answer due to a lack of foresight of the technology industry. Who knows what level of technology will be accessible in 1-5 years time (at the time of writing only ADSL internet at 1500 kbps is accessible and afford-ability of wireless devices is very low).

Conclusion

This now leaves us at the starting point in our build. We have a general overview of the needs of our client, and roughly an outline of the types of services that will be integrated.

In the next part of the series, I will be going through the basis of the network topology and the hardware that was purchased prior to and during the build.

If there is any questions or comments please leave a note, I would love to start some discussion on this topic as it seems to becoming more and more requested by the community.

Installing Ruby RVM on Ubuntu and Fedora


Installing ruby on Linux is easy, just run sudo apt-get install ruby or yum install ruby. However, version control can be difficult to manage. That is, scripts that run on a version on your computer may not run as well on another. So wouldn’t it be great if you could have 2 or more versions or the ruby interpreter on your computer.

To do this we will use the RVM – Ruby Version Manager. This is a great program, Allowing you to have complete environments for running ruby. This includes the interpreter and gems. And besides the few intricacies of setting it up, It is relatively easy to do.

My instructions are fairly similar to the official RVM instructions. You can find them at rvm.beginrescueend.com and more about RVM at there index page.

OK. Lets go..

Firstly make sure that you have a version ruby installed and curl for downloading the script (most distributions come standard with this, although minimal setups will not.

UBUNTU
sudo apt-get install ruby curl

FEDORA
yum install ruby curl

Now make sure that you are logged in as the user that you want to install ruby for. This may be a no brainier however, if you have more than one user you may wish to install ruby for everyone or for a specific person. I would very much suggest NOT install RVM for everybody, because different users may choose to run different ruby interpreters which may cause problems latter on down the track.

Time to get dirty with the command line.

Open up a terminal session and cd to your home directory. The first thing is to download the install script and run it in bash

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Once the script has run issue the following command to load RVM every time you login.

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

Now you need to close all your open terminal windows and then launch another. When the new one is open execute the following.

source .bash_profile

Now, to test that we have done all the previous correctly you need to use the following command and compare the results.

type rvm | head -l

The should output 'rvm is a function'

Thats it. Ruby Version Manager has been installed. Unfortunately, just having it installed is not much good, we need to look at gemsets and ruby versions, but that is for another post.

Quick Tip – Connecting to Another Machine (Linux to Linux)


In todays quick tip I will discuss methods of connecting to another computer. There are many different methods of doing this, even more if you want to mix and match between Windows, Mac OSX and Linux. Today I will just be looking at a Linux to Linux connection.

First off, for today I am going to be connecting to a system that I built for my parents (details of the build to come) to grab a few photographs that my dad took on his latest holiday. They have a central Linux system with a file server through port forwarding on port number 400.

The first method to connect is via a simple ssh shell command

ssh dad@X.X.X.X -p 400

Where dad is my dads username, X.X.X.X is his IPv4 address and -p 400 says that i want to connect on port 400 which will tell the router at my dads house that I actually want to talk to the file server. What I have now is a connection to file server and access to everything on that local machine, with the input output information sent to my machine.

So what can i do with this. Funnily enough, this simple command is powerful if you want to use the remote computer. You can run an update, run any command line program (cat /etc/passwd :P) or execute shell scripts to achieve tasks like backup or batch file manipulation. To copy files between computers we are going to need another command.

At this point we have three different options, two command line choices and one GUI, (the GUI only needs your computer to have the GUI not the remote computer.

scp dad@X.X.X.X:400/home/dad/image.jpg /home/me/image.jpg

or

sftp dad@X.X.X.X:400
get /home/dad/image.jpg

or

Places -> connect to server -> Fill out needed information -> connect
enter password -> navigate through window to file -> drag and drop to desired location

The first option is my favorite and the most simple command if you know exactly what you want and where you want to put it. The first part logs onto the ssh server and locates the file for copying, and the second part says where the file should be put. While it is simple, it has no margin of error, it either works or doesn’t, and can do some squiggly things.

The second option is the best for looking for and finding files without a GUI. You must first login to the ssh server in ftp mode and then find and “get” (download) the file. I don’t really use this option often, but it’s handy to know.

The third option is great if you want a graphical way of interacting file on an external server. This is very simple once you have seen what to do. Hopefully I will be able to do a quick video to show how to do this, which I will link at a later stage.

This outlines the way that you can connect to different Linux boxes on either you own subnet, or even over the internet. Stay tunned for more posts related to connecting computers, in particular mac and windows to linux connection.

Removing a file from the command line


In my last post I talked about the 3 main ways of creating files from the command line. Today I will look at how to remove a file. Generally, to remove anything you would use the following command.

rm myfile.text

This is a very simple command, although by using some flags we can make it both safer and easier to use. -I gives a prompt before removing three or more files or when removing recursively, -v (or –verbose) prints everything that has been removed. You can also use the sudo command to remove a file from a folder where you do not have permissions to write.
(more…)

Creating Files Using the Command Line


Trying to do a simple post a day can be quite difficult, I have found. Thinking up new and original content is nigh impossible everyday, and while I have a dozen or so major articles and tutorials in the works, today is going to be something simple.

To this end today I have decided to talk about creating files in the command line.

There are many options, although three come to mind, each with there specific purposes.
(more…)

Quick Tip – Fixing a Failed Apt-Get Update – Ubuntu


Woke up this morning, and as usually I had new software to download and install through updater on Ubuntu 10.04. So I click install updates and about halfway through updating it stops. No apparent reason, but the windows is frozen and cannot be closed.

After a quick search on the Ubuntu forums and a look at man apt-get, there appears to be a fix. (more…)

%d bloggers like this: