Support the ongoing development of Laravel.io →
Installation Configuration
Last updated 2 years ago.
0

Well, I too use mamp for testing out laravel on my local machine (I have a dedicated dev server for other stuff). Everything works just fine for me.

A few questions.

  1. What version of MAMP are you on?
  2. When you say your routes are not working...does it include the homepage (http://localhost) ?
  3. Post errors if you have any
Last updated 2 years ago.
0

Thanks for responding so quickly.

I installed MAMP 3

  • start/stop - everything is checked, and at startup open /MAMP/
  • Apache Port: 8888, MySQL Port: 8889
  • PHP 5.5.10
  • Apache Document Root "Projects" folder

I cd into Projects folder and ran composer and created a project called luna

When I navigate to localhost:8888 I see index of my project luna

If I click on luna I see the index with all the Laravel folders: git, contibuting, app, artisan, boostrap, composer,json, composer.lock, phpunix.xml, public, readme.md, server.php, vendor

I opened Projects > Luna > app > routes.php and tried a simple example from CodeBright:

Route::get('my/page', function(){
    return 'Hello World!';
}

Based on my understanding of routes, I assumed that I should be able to navigate to http://localhost/luna/my/page and see the "Hello World" message.

But I get an 404 error "The requsted URL /luna/my/page was not found on this server"

If I update routes.php to:

Route::get('/', function(){
    return View::make('hello');
});

Then when I go to localhost:8888/luna/public i get the "You Have Arrived" page

Last updated 2 years ago.
0

Let's forget about the mamp for now. Let's make sure your laravel installation works.

in the laravel directory, where you ran composer, type "php artisan serve". This will run an internal webserver, which opens up 8000 port by default. Once you have that, open your browser and access http://localhost:8000

If that works, you have an issue with your mamp configuration.

If it is mamp, check the following

  1. make sure you set the document root to the /public directory in your laravel installation.
  2. make sure you have enabled rewrite module in your mamp. Checkout http://stackoverflow.com/questions/7670561/how-to-get-htaccess-to-work-on-mamp

Let me know how it goes. If nothing works out, I will just send you my mamp config.

Last updated 2 years ago.
0

When I open my browser and access http://localhost:8000 I get the "You have arrived" page

  1. How do I set the document root to the /public directory?
  2. The code in the stackoverflow example looks a bit different than my file. I don't have tags with <VirtualHost>
  3. Allowoverride is set to ALL

Things are working when I use the default return View::make('hello');

But if I add my own route like:

Route::get('/',SomeController@index');

Then I get page error stating that something went wrong.

So as long as I use localhost/luna/plublic/ I can get to my pages

Is that correct? or is there a way to hide the /plubic from my dev environment?

Last updated 2 years ago.
0

Ok..that confirms that you've installed laravel correctly. It's matter of your server configuration now.

  1. Just point to public. In MAMP 3, click 'Preferences...' then click 'Apache' then change the Document Root to your 'public' directory. Restart MAMP.

  2. see if changing document root works.

IF NOT,

  1. Open /Applications/MAMP/conf/apache/httpd.conf

  2. Look for <Directory />

  3. change <Directory /> to <Directory /YOUR LARAVEL FOLDER/public>

  4. inside <Director> and <Directory, add

         Options Indexes Includes FollowSymLinks  
         AllowOverride All
         Order allow,deny
         Allow from all
    
  5. restart mamp and see if it works.

Last updated 2 years ago.
0

xuamox said:

Thanks for responding so quickly.

I installed MAMP 3

  • start/stop - everything is checked, and at startup open /MAMP/
  • Apache Port: 8888, MySQL Port: 8889
  • PHP 5.5.10
  • Apache Document Root "Projects" folder

I cd into Projects folder and ran composer and created a project called luna

When I navigate to localhost:8888 I see index of my project luna

If I click on luna I see the index with all the Laravel folders: git, contibuting, app, artisan, boostrap, composer,json, composer.lock, phpunix.xml, public, readme.md, server.php, vendor

I opened Projects > Luna > app > routes.php and tried a simple example from CodeBright:

Route::get('my/page', function(){ return 'Hello World!'; }

Based on my understanding of routes, I assumed that I should be able to navigate to http://localhost/luna/my/page and see the "Hello World" message.

But I get an 404 error "The requsted URL /luna/my/page was not found on this server"

If I update routes.php to:

Route::get('/', function(){ return View::make('hello'); });

Then when I go to localhost:8888/luna/public i get the "You Have Arrived" page

Make sure you delete the index.html in public

Last updated 2 years ago.
0

First of all, the mcrypt problem is not MAMP's problem!

Mac ships with a php version that doesn't come with mcrypt extension natively. Even if you install MAMP doesn't mean your computer is going to use the new PHP 5.5 interpreter.

If you do a check in terminal,

$ which php

You will probably get something like /usr/bin/php and this is not what you want. You should open up the .bash_profile ( if you don't have, create one. ) at your home directory /Users/yourname, and export the PHP you want the system to use.

For Instance, assuming you use PHP5.3.14, the newest MAMP should ship with PHP5.5, depends on your need, you should check out the /Applications/MAMP/bin/php folder to get the right PHP version you need.

export PATH=/Applications/MAMP/bin/php/php5.3.14/bin:$PATH

You are recommended to use virtual host when using Laravel. That should solve your 404 error.

$ sudo vi /etc/hosts

Enter your password, and add a line, for example 127.0.0.1 myapp.dev

Then, navigate to /Applications/MAMP/conf/apache/extra, Add the following line to this file. httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/your_laravel_installation/public"
    ServerName myapp.dev
</VirtualHost>

Finally, restart your apache server and access `http://myapp.dev" and see if it works. You would need to attach http:// in the very first time, as the internal DNS might not be wired up appropriately.

If I remember correctly, there shouldn't be any configuration you need to change to both MAMP and Laravel to boot your app.

Hope it helps.

Last updated 2 years ago.
0
$ which php 

returns: /Application/MAMP/bin/php/php5.5.10/bin/php

Last updated 2 years ago.
0

Good. Do you still have problems running php artisan ? If not, the CLI portion is good to go.

The web portion, did you setup a virtual host? The code I had above was assuming you use port 80 tho. You should be able to change that setting in MAMP.

Last updated 2 years ago.
0

Code Bright gives this as an example, and I tried to customize and implement, but then I can't restart MAMP server.

<VirtualHost *:80>

# Host that will serve this project.
ServerName      app.dev

# The location of our projects public directory.
DocumentRoot    /path/to/our/public

# Useful logs for debug.
CustomLog       /path/to/access.log common
ErrorLog        /path/to/error.log

# Rewrites for pretty URLs, better not to rely on .htaccess.
<Directory /path/to/our/public>
    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
</Directory>

</VirtualHost>
Last updated 2 years ago.
0

It shouldn't really matter where the location is. You just need to switch the location you are having. Let's try the most basic one ↓ ( Make sure the port is at 80 tho )

<VirtualHost *:80>
    DocumentRoot "/Projects/luna/your_laravel_installation/public"
    ServerName myapp.dev
</VirtualHost>

Try setup a virtual host and see if the routes are good.

You could make a test.php with phpinfo() in your public folder to see if it routes to the correct location.

If http://myapp.dev/test.php works,

For testing purpose, you should wipe out your routes.php.

Route::get('test', function() {
   return 'I am here';
});

if a plain route works, then it's your controller's problem.

PS Make sure you do $ php artisan dump-autoload When you create a controller or new model, you should try to do that to make sure those new files are autoloaded.

PS2 Check your log located at app/storage/logs/, see if there is any errors?

Last updated 2 years ago.
0

As a side note... I would recommend looking at Vagrant. I know you're only looking into Laravel for the first time recently, but once you start experimenting, a virtual machine is the way to go. It has the advantage of being an almost complete sandbox -- where you can play around and not worry about messing anything up. If anything goes wrong you can have a new VM up in seconds.

Here is a pretty good starting point for getting a fresh Laravel installation up and running in a few minutes. You won't look back!

Last updated 2 years ago.
0

It sounds like to me xuamox is new to MAMP and Laravel and never configured an Apache before.

xuamox, which example are you trying to do? what page are you on codebright?

It sounds like you're just copying and pasting without updating values of those configurations. It WILL not work if you just copy and paste. Point me to the example you're reading.

It's not Laravel issue. It's server configuration issues.

Last updated 2 years ago.
0

After countless hours messing around with MAMP, I have decided to use Vagrant instead. Vagrant is much easier to work with, and the installation process makes much more sense to me. Thanks for suggesting that I take a look at Vagrant. It's definitely the way to go for any beginner.

Also, for a really decent Bash file, check out: https://github.com/fideloper/Vaprobash/blob/master/Vagrantfile

Vagrant + Vaprobash has been a winning combination for me. I highly recommend it for anyone new to Laravel and virtual servers.

If you use Vaprobash, remember to use the "Develop" version of the Vagrantfile.

Kudos to Chris Fidao who contributed Vaprobash and has gone above and beyond to help users get started with Vagrant. and Laravel

Last updated 2 years ago.
0

So this one is not actually solved since the xuamox decided to ditch MAMP and use Vagrant instead. What about for those of us who want to use MAMP? I haven't been able to find an answer to this issue.

Last updated 2 years ago.
0

I have the solution to this problem. This also gave me many headaches starting out. I have learned to keep a journal of errors and issues I encounter with configuring applications.

If error PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory

in CLI

sudo mkdir /var/mysql

cd /var/mysql

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock

If php version pointing to Mac PHP version and not MAMP

then in CLI

touch .bash_profile

open .bash_profile

then type:

export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH

https://discussions.apple.com/message/20527774#20527774

http://laravel.io/forum/02-08-2014-difficulty-installing-laravel-getting-error-mcrypt-php-extension-required

To download Mcrypt PHP Library

http://topicdesk.com/downloads/mcrypt/mcrypt-download

Last updated 2 years ago.
0

awsp said:

It shouldn't really matter where the location is. You just need to switch the location you are having. Let's try the most basic one ↓ ( Make sure the port is at 80 tho )

<VirtualHost *:80>
   DocumentRoot "/Projects/luna/your_laravel_installation/public"
   ServerName myapp.dev
</VirtualHost>

Try setup a virtual host and see if the routes are good.

You could make a test.php with phpinfo() in your public folder to see if it routes to the correct location.

If http://myapp.dev/test.php works,

For testing purpose, you should wipe out your routes.php.

Route::get('test', function() {
  return 'I am here';
});

if a plain route works, then it's your controller's problem.

PS Make sure you do $ php artisan dump-autoload When you create a controller or new model, you should try to do that to make sure those new files are autoloaded.

PS2 Check your log located at app/storage/logs/, see if there is any errors?

awsp, my test.php works, but my basic /test route does not. Any suggestions?

Last updated 2 years ago.
0

How about ...

http://myapp.dev/index.php/test

If above is working, maybe you want to check Apache's configuration. You should probably check if your mod_rewrite is working correctly. If I remember correctly, somebody had a problem from IRC that his Apache setting didn't allow individual .htaccess to be overridden. I guess it's also a good idea to check that out as well.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

xuamox xuamox Joined 1 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.