I have MAMP installed on my Mac with MacOS HighSierra 10.13.4.
I have ran composer create-project roots/bedrockin my /Applications/MAMP/htdocsfolder.
I have started up my servers via the MAMP UI. When I surf to http://localhost:8888/MAMPI get the MAMP startpage so everything seems to be working fine.
When I go to http://localhost:8888/bedrock I get a list of my files and dirs in my bedrock folder:
Index of /bedrock
Parent Directory
.env
.env.example
.gitignore
CHANGELOG.md
...
This is what my .env file looks like:
DB_NAME=adatabase
DB_USER=auser
DB_PASSWORD=apassword
# Optional variables
# DB_HOST=localhost
# DB_PREFIX=wp_
WP_ENV=development
WP_HOME=http://localhost:8888/bedrock
WP_SITEURL=${WP_HOME}/wp
I am wondering what I am doing wrong since I don't see the WordPress installation page.
It looks like apache, by dint of MAMP's default config, isn't serving from the correct directory for a bedrock project.
According to the bedrock docs, you should:
Set your site vhost document root to /path/to/site/web/ (/path/to/site/current/web/ if using deploys)
So, you'll need to modify your MAMP config to serve this project not from /Applications/MAMP/htdocs/bedrock, but from /Applications/MAMP/htdocs/bedrock/web.
You will need to click Set Web & MySQL ports to 80 & 3306 via MAMP > Preferences > Ports.
Then http://localhost/bedrock
Please let me know if this works :)
Related
I have created small blog application in laravel 5.2 .the app works whenever i run it using php artisan serve.
But without running artisan serve , when i access it from public folder for e.g. localhost/blog/public/addBlog it gives error page not found.
My routes.php has following lines
Route::get('addBlog','BlogsController');
It works fine with php artisan serve with visiting http://localhost:8000/addBlog
The solution is pretty simple. Laravel expects your public folder to be the root of the webserver / url / domain.
Using the serve command works since localhost:8000 is the root then.
Using the longer url doesn't work since your root is localhost/blog not localhost.
A fairly simple solution is to create a virtualhost, to explain how you can do this we would need to know what is running on your localhost (xampp? wamp?)
Nevertheless, the solution would be a virtualhost pointing to localhost/blog/public
Update
example for wamp virtual hosts
C:\Windows\System32\drivers\etc\hosts => open as admin and add
127.0.0.1 blog.dev
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerName blog.dev
DocumentRoot "C:\wamp\www\blog\public"
ServerAlias blog.dev
</VirtualHost>
It's basically the same for xampp, but the path to the vhosts conf is different
Don't forget to restart wamp/xampp after doing the changes. Then simply open http://blog.dev via browser and enjoy
Laravel expects the folder to be in the root of the application so set-up a virtual host and update your hosts file to match.
Use following command
sudo a2enmod rewrite
I had tried in to the ubuntu but i am not sure that will run in another os or not
I am trying to install Laravel 5.2 and I got to the point where I am configuring homestead.yaml file. I understand that /home/vagrant/Code/Laravel/public is where my project files should be located:
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
I am on Windows 7 and I can't find where this /home folder is. Does anyone know where it is? Or is my laravel project located in another folder?
This folder is inside virtual machine. You need to map real folder on your PC (like C:\Laravel\public) to VM folder /home/vagrant/Code/Laravel/public.
You can use your VM with SSH client, like WinSCP and you'll see all folders there:
host: 127.0.0.1
login: vagrant
password: vagrant
That configuration option is where you provide virtual hosts for various applications that you'll be using homestead for.
By default, when you configure homestead you specify a directory that you want mounted onto the virtual machine, for me it's D:\Users\me\Projects\PHP. Homestead mounts this folder to /home/vagrant/Code.
That path is for the virtual machine and only the last part after /Code has any connection with your actual Windows machine.
It's by default located realtive to your home directory on windows, i.e.
C:\Users\[user]\Code
Note: you might want to create the Code folder first inside C:\Users\[user]
I have been using XAMPP for quite a time, and after discovering Laravel and finding out, that I quite like it, I also wanted to use Homestead. The problem I'm having is, that I can't seem to be able to run multiple sites.
I have tried various things, but the main problem currently is, that one project works, while all the others are getting a connection timeout, when trying to access their webpage.
These are the steps I've taken to use Homestead
Installing VirtualBox
Installing Vagrant
Adding homestead with vagrant box add laravel/homestead
Clonging the repository git clone https://github.com/laravel/homestead.git Homestead
Create Homestead.yaml file in the Homestead directory with the bash init.sh script
Create a new project laravel new projectA
Require homestead composer require laravel/homestead
Generate Vagrantfile php vendor/bin/homestead make
Modify the Homestead.yaml to have an IP that ends with 10
Create another project laravel new projectB
Require homestead composer require laravel/homestead
Generate Vagrantfile php vendor/bin/homestead make
Modify the Homestead.yaml to have an IP that ends with 11
Adding those two sites to the hosts file sudo nano /etc/hosts => xxx.xx.xx.10 projecta.app & xxx.xx.xx.11 projectb.app
Starting vagrant from one of the two directories vagrant up
Now, I'm having the problem, that only one of the projects is reachable. It's always the one from where I called vagrant up. So if I call vagrant up from Project A I can access http://projecta.app and http://projectb.app times out. The same the other way around, sadly.
This is my vagrant global-status
id name provider state directory
------------------------------------------------------------------------
fc6fadb default virtualbox running /Users/mknb/work/projectA
I thought I would just do another vagrant up from the projectB directory but that doesn't work of course.
I don't want to use the global Homestead, because Laravel said, that it is possible to have a per project installation, so how do I achieve it? Do you need more information?
I didn't modify the Homestead.yaml except of the IP and the domainname homestead.app => projecta.app
It seems like a global installation is fairly easy with Homestead, since I would just have to add more sites to the Homestead.yaml, but as I said I'd like to have a per project installation. Can anybody help?
Starting vagrant from the Homestead directory doesn't work of course.
By using Homestead in your way, you create a virtual machine for each projects. Therefore, the VirtualBox cannot forward the HTTP request from your host machine for all of virtual machine. You can only run one machine (so, one project) each time.
To run multiple projects with Homestead, you can do as follow:
Clone Homestead git clone https://github.com/laravel/homestead.git Homestead
Inside the Homestead folder, run bash init.sh
Edit the folders property of ~/.homestead/Homestead.yaml to share your code of both projects with VM:
folders:
- map: ~/pj1
to: /path/to/project1
- map: ~/pj2
to: /path/to/project2
Edit the sites property of ~/.homestead/Homestead.yaml to make Nginx enable the domain of both site:
sites:
- map: project1.local
to: /home/vagrant/pj1/public
- map: project2.local
to: /home/vagrant/pj2/public
Edit your hosts file to forward these domain fo localhost
127.0.0.1 project1.local
127.0.0.1 project2.local
Run vagrant up at the folder that you cloned the Homestead code inside it (which contains the init.sh file).
Now, you can run as many project as you want with just one Homestead virtual machine.
There are some important steps missing in the accepted answer although it helped me lot. I have added those necessary steps. Thanks #Hieu Le for answer.
I assume you have correctly installed your fist site as by the instructions of Laravel docs. Now you have another laravel site which you want to shift on vagrant. Follow the following steps.
cd into the directory of new Laravel project which you want to add. I assume you have all laravel files in it and its working using MAMP or any non-vagrant solution.
run vagrant init laravel/homestead. This command will add the necessary VagrantFile in this new project.
open the directory of your first original project file and open its
Homestead.yaml file in editor.
Now follow the steps defined by #Hieu Le in accepted answer to
modify .yaml file
folders:
- map: ~/pj1
to: /path/to/project1
- map: ~/pj2
to: /path/to/project2
sites:
- map: project1.local
to: /home/vagrant/pj1/public
- map: project2.local
to: /home/vagrant/pj2/public
Edit your hosts file to forward these domain fo localhost
127.0.0.1 project1.local
127.0.0.1 project2.local
On terminal cd into your first original original project
directory.
Run command vagrant reload --provision. This will reload the
vagrant machine so that the changes which we made in .yaml file come in effect. You database of original project will remain intact.
Run vagrant ssh
Run ls and make sure you can see the folder of your new project. If its there
you have configured your new site correctly.
Hit the url of new site with addition of http:// and your are
DONE.
Like how here says, you can install Homestead directly into your project, require it using this composer require laravel/homestead --dev at root directory of each project you have. Now by make command you can generate Vagrantfile and Homestead.yaml file into your project's root directory.
Mac/Linux:
php vendor/bin/homestead make
Windows:
vendor\bin\homestead make
On each project root you will have a Homestead.yaml file to edit:
Project-A
ip: "192.168.10.10"
...
folders:
- map: "~/Code/projecta"
to: "/home/vagrant/projecta"
sites:
- map: project.a
to: "/home/vagrant/projecta/public"
Project-B
ip: "192.168.10.10"
...
folders:
- map: "~/Code/projectb"
to: "/home/vagrant/projectb"
sites:
- map: project.b
to: "/home/vagrant/projectb/public"
Add this to /etc/hosts:
192.168.10.10 project.a
192.168.10.10 project.b
Then you have to cd to each project's root and vagrant up.
Now if you vagrant ssh from each project, you will have that project in your VM environment.
there is a short cut command to proxy the sites you want to add..
without having to messed up your Homestead.yaml file and provision your vagrant box all over again...
This applies to BOTH GLOBAL AND PER PROJECT INSTALLATION
Just Make sure if you are adding another project...
You add it the (whole project) on your Shared Folder
Declared in your Homestead.yaml
Assuming your shared folder is
C:/Users/MYACCOUNT/Codes
Add another project in that Folder
laravel new homestead.app
Then
Assuming your are ssh in your Homestead
Type
a.) if your using nginx
serve homestead.app /home/Vagrant/Code/homestead/public
b.) if your using hhvm
serve-hhvm homestead.app /home/Vagrant/Code/homestead/public
Just change your domain name and path to public folder of your project
Then Edit your etc/hosts file as Administrator
What ever ip address you define in your Homestead.yaml
usually the default is 192.168.10.10
Use it instead of 127.0.0.1
Why? because if you use 127.0.0.1 your url will look like
homestead.app:8000
If you Use the IP address in the Homestead.yaml
192.168.10.10 homestead.app
you can access your site without port 8000
and just use homestead.app
This Solution is Much Better than Provision... And is Faster...
This is what i Do
Step 1: First you just map your other project and database in the homestead.yaml file enter image description here.
Step 2: Create the database you mentioned in the existing workbench connection enter image description here.
Step 3: Mention that database in your project .env file. enter image description here
Step 4: Add another path in your drivers/etc/hosts file and run homestead reload --provision. Your problem is solved. :)enter image description here.
I have PHP with Apache2 and I want to run Laravel Framework without Artisan but I can't! Does anyone know how to run Laravel without Artisan?
I've solved the problem. The problem was in my htaccess and in mod_rewrite (Apache2). Now I can connect to my application only by typing localhost/public..
If anyone wants to make the application public, the more easy and fastest way is:
Rename the "server.php" file in root directory, in "index.php"
Move your .htaccess from public folder to root directory
Make your directory accessible to Apache2 (set correct file/folder permissions).
Thanks to all users for help! :)
Important Edit
Consider using Apache Virtual Hosts (pointing the virtual host to the /public Laravel folder) instead of renaming server.php to index.php because by doing this you will need to prefix "public/" when you use the Laravel's asset() function in your views.
When working with other devs, who are using a different configuration, this might be a big problem because they will be able to see the assets while you will not (or viceversa).
I am using xampp in mac
inside htdocs / run following command:
$ laravel new myblog
After successfully creation run following and do following:
sudo chmod -R o+w storage/
Change server.php to index.php (# root directory)
copy .htaccess from public to root directory
(optional) in resources / app.blade.php → Change to
<link href="{{ asset('public/css/app.css') }}" rel="stylesheet">
run following
http://localhost/myblog/
Easy solution without any code alterations
Point your domain to public/ folder of laravel project.
Enjoy!
~OR~
Create .htaccess in project folder and add below code. This code will rewrite domain to public/ folder of your laravel project
RewriteEngine on
RewriteRule ^(.*)?$ ./public/$1
Hope this is helpful.
Laravel framework is such a pain in the ass for startup PHP guys who are not much oriented about what the hell composer is, and where .phar files are coming from and what are they, and why "Artisan" is trying to ruin your PHP life.
Most people are looking for a PHP framework where all you have to do is download, extract and code.
Nevertheless to make things work, you just need to install Laravel through Composer:
composer global require "laravel/installer=~1.1"
Anyway, you can download Composer from http://getcomposer.org/
After you install Laravel through Composer, navigate to your local server's directory. You might want to use "CD" (Change directory) to do this. (I'm speaking of CLI, whether you're in BASH(Linux) or CMD(Windows))
Then create your very first Laravel project by typing this in command line:
laravel new mywebsite1
Replace "mywebsite1" with your first project name.
And there you go, you're ready to hit the Laravel road.
In my case, I'm still using Windows XP in such development and shifts back to Ubuntu Trusty whenever I feel like I want to smell Linux scent.
So Composer installs "Laravel installer" in:
%userprofile%\Application Data\Composer\vendor\bin
So I make a backup copy of this directory so the next time I use Laravel on other unit with no internet connection, I just have to extract it, and run:
laravel new [myprojectname]
within the same directory and copies the resulting folder to my XAMPP's htdocs or WAMP's www folder.
Anyway I'm just sharing my approach for those with no 24/7 internet connection at home :p
After all it's still best for everyone to read the documentation on how to properly install Laravel: http://laravel.com/docs/5.0/installation
For Windows Users Its very easy to change and run laravel projects on your normal project urls :
1. "server.php" to "index.php" .
2. copy ".htaccess" from public to root directory.
there you go with your normal URL .
localhost/project_name
Artisan is simply a command line interface. It is made to do things like create and run migrations and automate building certain objects within your Application, etc. Essentially, it's only made to help facilitate creating and working on your Application, not run it.
If you are having issues actually getting the Application to run, it is likely a problem with either your PHP or Apache, not Artisan.
Just Follow 3 Step ;
Change File Name : change serve.php to index.php inside your Project name folder.
Move .htaccess file Bring ".htaccess" file to main root [inside your Project name folder ].
Restart your local server. Your are just 1 click away . Restart all services of xampp or wamp
Enjoy
For an aternative maybe you can run it under a virtual host. All you need is just create a new virtual host with your project/public directory as a DocumentRoot.
In my case, I am using XAMPP under Mac OS. These are the steps on how to achieve that:
Enable virtual host config
Ensure virtual host config was enabled, else you can enable it through this file: /Applications/XAMPP/xamppfiles/etc/httpd.conf
$ sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
Remove the hash "#" of this following line
# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Add a new virtual host
$ sudo nano /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
The add a new virtual host (e.g: newproject.dev)
# Virtual host of newproject.dev
<VirtualHost *:80>
ServerName newproject.dev
DocumentRoot "/Users/your-username/newproject/public"
<Directory "/Users/your-username/newproject/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Note: /Users/your-username/newproject/public is the location of your project.
Update your hosts
$ sudo nano /etc/hosts
Add this following setting:
# Host of newproject.dev
127.0.0.1 newproject.dev
Restart your Apache, go to your browser and your project should be available on http://newproject.dev
I got mine to work by adding the following block to my apache vhost conf file
<VirtualHost *:8003>
ServerName myproject
DocumentRoot "/path/to/myproject/public"
</VirtualHost>
and running sudo chown -R daemon storage from my project root
Well , the easy way is
1) create a new folder"Project" and copy all files except public folder content to project folder
2) copy all files of public folder to root
and you can run laravel without artisan.If you rename server.php and copy .htaccess , it may make trigger some error when you try to run auth artisan command.I experienced problem with auth command.
Laravel with Vue.JS
If you are using vue.js with Laravel and your app is not working without php artisan serve, you need to create a virtual host. This is a simple two-step process for windows.
Step 1: Update you hosts file at C:\Windows\System32\drivers\etc with,
127.0.0.1 dev.example #You can rename according to your app
Step 2: Update you vhosts file with,
I am using Apache which is installed in D:\ so my path for vhosts file is at
D:\xampp\apache\conf\extra
<VirtualHost *>
DocumentRoot "D:\xampp\htdocs\example\public" ##Your path
ServerName dev.example ##Your URL according to what you set in hosts file in step 1
<Directory "D:\xampp\htdocs\example\public"> ##Your path
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That's it, now you can just visit your app at http://dev.example/
Install and setup Laravel on your local (meaning your local machine).
Once done, copy all files to your hosting.
Create a .htaccess file on your Laravel's root directory. This is to access it without the "public" on the URL.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
I have created a fresh Laravel application by using composer create-project command. Then I put all the folders and files in /usr/share/nginx/html/, which is the default document root for my nginx server. However everytime I runs the http://localhost, it keeps displaying 403 Forbiden. I tried creating a testing index.php (<? php_info();) and it worked fine.
I've read somewhere that I need to set the containing folder (/html), as well as the app/storage folder permission to 777 but still no luck.
Please help me. Thank you in advance.
Here is the nginx default.conf
Laravel projects serve from the <projectName>/public directory. Make sure your nginx config is set up to look there for your index file and NOT in your <projectName> folder only.
Would you edit your question and paste your server config there?
I think it may because index.php is not in the index file list. check these lines:
index index.html index.php;
or
try_files $uri $uri/ =404;
The accepted answer is correct - Laravel services from the public folder and you need to tell nginx to look there - but also a little vague if you're bumping up against this problem. When you create new sites on a Homestead installation by adding them to your .yaml file and using vagrant provision or vagrant up --provision, the created nginx conf file will need editing before Laravel will serve files correctly.
Go to your CLI, and enter Homestead using vagrant ssh or homestead ssh. It will ask for your password, which by default is "vagrant".
Once you're in the virtual machine, type the following commands:
sudo nano /etc/nginx/sites-enabled/your-site-name-here
Then add /public to the end of the existing root near the top of the file (it'll be something like /home/vagrant/projects/your-site to begin with and save in Nano (ctrl+s), then exit nano (ctrl+x).
Once you've exited Nano, restart nginx using sudo nginx -s reload. Your routing will now work!