Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Tuesday, February 12, 2013

Laravel - Getting UniServer Ready For Laravel Applications



- Laravel requires a web server environment and will run in Apache, IIS, and Nginx easily.
- Laravel should run in any server environment that supports PHP. The easiest way to
set up a local webserver for development is to install XAMPP (Windows), MAMP (Mac
OSX), or Apache with PHP5 on through a package manager on Linux.
- Laravel is written in the PHP scripting language. Currently, Laravel v3.2.5 requires a
minimum of PHP v5.3 to run.
(PAGE 5)
1) Web application development is very dynamic and flexible.
1.1.) Dynamic → Keeps on changing and improving.
1.2.) Flexible → Many ways of getting the same output.
2) For the purpose of Laravel Framework experimentation, we will be using the following software tools:
2.1.) UniServer (downloadable from http://www.uniformserver.com/  )
2.2.) Notepad++ (downloadable from http://portableapps.com/apps/development/notepadpp_portable )
3) As a prerequisite, a person wishes to learn Laravel should have some backgrounds in:
3.1.) PHP codes
3.2.) DOS/Shell commands
4. Running a HTTP server.
4.1) Download UniServer, extract it to a proper location (e.g. c:\z\dev\  )
4.2) Observe the contents of UniServer.
4.3) Run UniServer by Double-Clicking the “Start_as_program.exe
4.4) Answer No for password change option.
4.5) Answer Yes to disable password check prompt in the future.
4.6) If you receive a warning message that port 443 is used by other program, Click Server Configuration/Apache/Edit httpd-ssl.conf and change “443” to “4431”.
4.7) Click Start Both button and Check that Apache and MySQL are running.
If Windows Firewall pops up, select the option to unblock Apache and MySQL.
4.7) Click View www.
4.7.1) A web browser should pop up and display the URL http://localhost
4.7.2) Replace the url with the number 127.0.0.1
4.8) From here, we have observed a few things:
4.8.1) Extracting UniServer to C:\Z\DEV\ .
4.8.2) Run “Start_As_A_Program.exe” .
4.8.3) Warning to Change MySQL Password .
4.8.4) Warning to Change Port 443 etc.
4.8.5) Option to disable Warnings in future runs.
4.8.6) “Start Both” button.
4.8.7) “View www” button.
4.8.8) Localhost host name.
4.8.9) 127.0.0.1 IP number for Localhost.
Read more about localhost and 127.0.0.1 at http://en.wikipedia.org/wiki/Localhost 
5) Check PHP Server Configuration.
5.1) Go to UniServer Control Panel.
5.2) Click View phpinfo.
5.3) Check that the PHP version supports Laravel and Virtual Directory

- We need to choose a host name for our example application. This is our first application and we're working on our local development environment, so let's usehttp://mysite.dev.
- an example of host IP and and host name configuration setting:
127.0.0.1 mysite.dev
- In Linux and OSX, simply add the above line to your /etc/hosts file:
- Windows users should add that line to their c:\windows\system32\drivers\etc\ hosts file.
- Now you should be able to ping myfirst.dev and see that it resolves to 127.0.0.1.
(PAGE 5)
6. Create new hostname, mysite.dev .
6.1) We will create a special hostname for our application. This is called a virtual host. This requires two step; 1) Edit Windows hosts file, 2) Configure Apache Virtual host file.
6.2) Run Notepad as an administrator.
6.3) Open C:\Windows\System32\drivers\etc\hosts.
6.4) Look for the entry 127.0.0.1
6.5) Add a new entry (Web Address such as mysite.dev)
6.6) Save the file and restart your PC.
6.7) Browse mysite.dev. You should see the previous page loaded at this address.
6.8) Run Command Window and type ping mysite.dev. Notice that the hostname resolves to 127.0.0.1.
7) Up to this point, we have:
7.1) Prepared the HTTP server to run Laravel application.
7.2) Prepared a virtual host name mysite.dev as the web address of our Laravel application. (Using Virtual Host is practical when you want to store many sites on the same physical server. In addition to this, Virtual Hosts will help us to keep our tutorial exercises on separate directories)

The easiest way to download Laravel is as a compressed package from
Alternatively, you can download Laravel by cloning its git repository from GitHub.com
with the following command.
git clone git@github.com:laravel/laravel.git
It would be better that you download the most current stable build.
Extract the contents of the compressed package into the directory that you store your
web-applications.
E.g C:\Z\Dev\UniServer\vhosts\a.
(PAGE 5)
8) Creating Laravel Application Directory.
8.1) We will create a dedicated directory for mysite.dev (This is also called virtual host directory. Whenever a web client browse mysite.dev, the server will look for the applications at this directory).
8.2) Using Windows File Explorer, Go to UniServer root directory (e.g. C:\Z\Dev\UniServer ).
8.3) Create a new directory “vhosts” (if it doesn’t exist).
8.4) Extract Laravel to a folder “a” as shown below.
8.5) Take note of the full path to Laravel application files and directories (We will call this as  {Laravel Root} ) (e.g. C:\Z\Dev\UniServer\vhosts\a )
8.6) Check {Laravel Root}\public\.htaccess file.
It would be like follows:
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
<IfModule mod_rewrite.c>
        Options +FollowSymLinks
        RewriteEngine On
</IfModule>
# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact
<IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
9) Register Laravel Root as UniServer Virtual Host.
9.1) On UniServer Control Panel, click Server Configuration\Apache\Apache Vhosts.
9.2) A Virtual Hosts Dialog Window pops up. Look at the List of Hosts section. Click localhost. The setup details will appear at the Virtual Host Setup section.
9.3) Click Cancel. The window is ready to register a new Virtual Host details.
9.4) Select Folder that points to {laravel home}\public\. Type Server Name. Click Confirm.
9.5) The configuration string is auto generated.
9.6) Take note of the configuration string:
<Directory "C:\Z\Dev\UniServer\vhosts\a">
  Options Indexes Includes
  AllowOverride All
  Require all granted
</Directory>
9.7) Click Create Vhost button. The new Virtual Host Name has been added to the list. You will be reminded to restart Apache Server.
9.8) Restart Both Apache and MySQL Server.
9.9) Browse mysite.dev
Look at the path. It is pointing to {laravel root}\a\...
9.10. Re-Check {Laravel Root}\public\.htaccess file.
Compare against step 8.6.
If the content has changed, rename it as .htaccess.bak .
Create a new .htaccess and copy the content in step 8.6  into it.
10) TRY: create an alternative directory for mysite.dev
10.1) duplicate folder a as b.
10.2) Set b as new directory for mysite.dev virtual hosts.
10.3) Restart server.
10.4)If you are successful, you should notice the new path displayed on the page

1 comment:

  1. Dear Madam/Sir
    I am an user of uniform server and your post was found after search on web
    your post is quite interesting to me but many pictures are lost in your post. It is what a pity
    would you be kind enough that I may get pdf copy of your post in order to study in detail ?
    Andrew

    ReplyDelete