Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Windows installation, one step from total bliss!
  • This is for extremely newbies (and noobs like me), who quit with the first hurdles during installation (of anything). I decided to give fuelphp a second try and I came close, but not yet there...
    My (vintage) environment : Windows XP with wamp server installed (the easy part) on E:, so my local web root is e:\wamp\www.

    Steps :

    1) Do yourself a favor and download and install git from : https://help.github.com/articles/set-up-git (Github for Windows, green button up right).
    Now you have two apps, a GUI to manage your github repositories and MOST IMPORTANT, a command line Git Shell, which is a Windows PowerShell and you can now run git commands (eg clone etc).

    2) Do yourself a second favor and download and install Composer (http://getcomposer.org/Composer-Setup.exe). Choose global installation and now you can use composer from the command line (preferrably git shell) . Forget every composer.phar you see, it's a local copy o composer wherever you happen to be.

    3) Make a folder to hold you fuel projects (mine is E:\fuelsites). Download Fuel 1.6 and unzip it there, you will have a folder fuelphp-1.6. Copy everything from this folder one level up, to e:\fuelsites. Delete folder fuelphp-1.6.

    4) Inspect folder e:\fuelsites. There is composer.json file, so we can install any dependencies fuel needs. Fire up Git Shell, cd to folder e:\fuelsites and write : composer install. We stll have way to go...

    5) Inside e:\fuelsites\fuel there is folder app. There goes the code of our application. WAIT! I want to make a hundred,a thousand application with fuel. Do I have to install it a thousand times? I guess no. Make two folders in e:\fuelsites\fuel with names eg. myapp1 and myapp2. Copy everything from app folder in these two folders. Delete app folder if you like.

    6) Inside e:\fuelsite there is a public folder. There you can store the stylesheets, js etc for your app. But we have two applications and each one uses its own assets. Make two folders public1 and public2 and copy in these everything from public. Delete public if you will.

    7) Now we must setup two virtual hosts, one pointing to public1 and one to public2.
    Find your Apache configuration file (httpd.conf), mine is in
    E:\wamp\bin\apache\apache2.2.22\conf .
    Edit it (I use notepad++). Find the lines :
     # Virtual hosts
    # Include conf/extra/httpd-vhosts.conf  -> Remove # from this second line .
    Now apache searches for virtual hosts in folder extra, file httpd-vhosts.conf .
    Go to folder extra and edit file httpd-vhosts.conf . Put a # at the start of every line that does not have one (they are just examples). Write the following :

    <VirtualHost *:80>
        DocumentRoot "e:/wamp/www/"
        ServerName localhost
           <Directory "e:/wamp/www/">
               Options Indexes FollowSymLinks MultiViews
               AllowOverride all
           </Directory>
    </VirtualHost>

    <VirtualHost 127.0.0.3:80>
        DocumentRoot "e:/fuelsites/public1"
        ServerName fu_myapp1.pet3
        <Directory "e:/fuelsites/public1">
            Options Indexes FollowSymLinks MultiViews
            Order Allow,Deny
            Allow from all
            AllowOverride all
        </Directory>
    </VirtualHost>

    <VirtualHost 127.0.0.3:80>
        DocumentRoot "e:/fuelsites/public2"
        ServerName fu_myapp2.pet3
        <Directory "e:/fuelsites/public2">
            Options Indexes FollowSymLinks MultiViews
            Order Allow,Deny
            Allow from all
            AllowOverride all
        </Directory>
    </VirtualHost>

    First I define localhost (e:\wamp\www) as a virtual host , if I omit this I have troubles on my PC!
    Then I define a virtual server by the name : fu_myappa1.pet3 that points to e:/fuelsites/public1 (notice the slashes). fu is from fuel and pet3 from my name (Peter, obviously I use pet1 and pet2 for something else!). I use this ridiculous naming to make clear that IT IS NOT MANDATORY to name it myapp1 or anything. I also make Apache listening to address 127.0.0.3 just to say that we can do it (use 127.0.0.1 if you want). Do the same for fu_myapp2.pet3.

    8) We must tell Windows of our new servers. Go to c:\windows\system32\drivers\etc and edit file hosts. Add the lines :
    127.0.0.3       pet3
    127.0.0.3       fu_myapp1.pet3
    127.0.0.3       fu_myapp2.pet3

    (I do not know if the pseudo-domain pet3 is necessary here!)

    9) Set the application path for fuel. In public1, edit file index.html and amend line 27 to read :
    define('APPPATH', realpath(__DIR__.'/../fuel/myapp1/').DIRECTORY_SEPARATOR);
    Do the same for index.html in public2 replacing app with myapp2.

    10) In E:\fuelsites\fuel\myapp1\views\welcome edit index.html and add the number 1 after the Welcome word. Do the same in myapp2\views\welcome adding a 2 in index.html welcome message.

    11)In the browser write : fu_myapp1.pet3 and voila! we see fuels welcome screen with the 1 we wrote. Write fu_myapp1.pet3/hello and we see the Hello message, so routing is right???

    12) Now if we give fu_myapp2.pet3 we must see Welcome 2... BUT NO!!!! we see Welcome 1.

    So, here I am. What should I do to make it work? (I have played with .htaccess ad nuseum, but to no avail).

    Any help welcome!

    Petros

  • Our setup is a little bit different:

    We too have a central location for all framework files, but we leave the 'fuelphp-1.6' in place because there will come a time when you have to run multiple versions.

    For the application side, we have a standard base installation, from which we have removed "fuel/core" and we have emptied "fuel/packages". The virtualhost docroot will point to the public folder in this base install.

    You then open de index.php in /public, and change the COREPATH to point to the centrally installed fuelphp-1.6/fueil/core. Also change the COREPATH in the oil file in the root of your app installation if you want to use oil.

    No other changes are needed, this works fine, and is perhaps a little less complex. You will have a better separation between core and app code.

    So, we do it the other way around, we use a standard installation for every virtual host, but have centralized the framework core and packages. Instead of splitting off public and app within the framework installation.

    With regards to your hostfile entries: most modern browsers are becoming very picky when it comes to RFC standards. Some don't even accept 'localhost' anymore, as it violates the RFC hostname standard, which says that a hostname MUST have a dot and a toplevel domain in it. So yes, the '.pet3' is needed.
  • To debug this issue:

    Put a die() statement in both index.php files, with a "1" and "2". Test it again. If it both shows one, you have an Apache issue, as both virtual hosts load the same index.php,

    If you do get "1" and "2", then the index.php loads the wrong application, and you'll have to look into that.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion