Install Magento 2 with Nginx on Laravel Forge

Install Magento 2 with Nginx on Laravel Forge

Here's to do it.

  • Create site at Laravel Forge control panel
  • set web directory to /pub
  • ssh into your server
  • get Magento via composer
composer create-project --repository-url=https://repo.magento.com/magento/project-community-edition .
  • setup proper file permissions
find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {}\;

Now if you hit your domain url if you're unlucky you won't see an installation wizard. Inspect page and go to console tab and you'll see like side menu panel not found etc.

Laravel Forge nginx config located in
/etc/nginx/sites-available/domain.conf and you should include magento nginx sample in server block config.
include /home/forge/#YOURDOMAIN#/nginx.conf.sample;

And now the fix that worked for me is you should and edit php.ini file which is in /etc/php/7.1/fpm/php.ini and set
cgi.fix_pathinfo=0
to
cgi.fix_pathinfo=1
and run
sudo service php7.1-fpm restart and sudo service nginx restart

Now hit your magento installation domain url and you should see an install wizard.

Good luck!

PS If you are migrating from one server to other and exporting database, while importing you might encounter problems where the error is thrown on columns update_at. It is because of MySQL strict mode is on. So you need to turn it off.
Edit /etc/mysql/mysql.conf.d/mysqld.cnf
and under [mysqld] add
sql_mode = '';
and run
service mysql restart

Now you should import your database without any problems. After database imported I suggest to turn strict mode back on.