Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Homestead vhost configuration

I am using Laravel homestead. For a project I need a special vhost configuration, where should I define this?

like image 484
Alexander Cogneau Avatar asked Aug 12 '14 15:08

Alexander Cogneau


People also ask

How do I connect to Homestead database?

Connecting To Your Databases To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0. 0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret .

How do I change PHP version to Homestead?

As a slightly simpler alternative to update-alternatives --config php you can enter the PHP version you want on the command line with a syntax of php71 where 7 is the major version and 1 the minor version. For example to switch to PHP 7.1 from another version simply type php71 .

Which of the following is the correct command to install Homestead?

Installing Homestead Next, execute the bash init.sh command from the Homestead directory to create the Homestead. yaml configuration file. The Homestead. yaml file is where you will configure all of the settings for your Homestead installation.


2 Answers

You add a new folder mapping into the "sites" block of Homestead.yml, like so:

- map: myapp.com
  to: /home/vagrant/Code/myapp/public

That's all there is to adding a new vhost. To modify it, edit the appropriate file in /etc/nginx/sites-available. In the above case, this would be /etc/nginx/sites-available/myapp.com

See here for example customization of a newly added vhost. Note that the quick tip linked here uses Homestead Improved, a slightly enhanced version of Homestead, as described here.

More Homestead related posts can be found on our site via the Homestead tag.

like image 145
Swader Avatar answered Sep 20 '22 12:09

Swader


I have been looking for a solution for customizing nginx vhosts. You want to do it in provisioning, or better: after provisioning otherwise Homestead will overwrite any changes you have done manually to the vhost files.

One solution is the one I found here: https://laracasts.com/discuss/channels/requests/homestead-provision-deletes-custom-nginx-settings

Basically you create configuration files in a folder in the host machine, map that extra folder to the vagrant machine, then in your after.sh file (which is run by homestead after the normal provisioning is finished) you just copy all of them to nginx's sites_available folder.

like image 44
smarques Avatar answered Sep 22 '22 12:09

smarques