Ben's developer blog
Welcome to my blog. I'm a developer and I created this blog as a place to share things I learn that I think will be useful to other developers.

Install Magento 2 on a Forge managed server

Posted on Sunday 20th January 2019

Recently I had to get Magento 2 running on a Forge managed server. I found a great article which gave me the basic instruction I needed to get up and running. You can find that article here. It took me a little while to get it up and running so I thought I'd put together an article myself with more detail and some screen shots.

To start you will need to set up a new website on your Forge server. By default Forge will set the web directory to "/public" you will need to change this to "/pub".

Forge site setup

Forge site setup


Next you need to connect to your forge server using SSH and navigate to the website folder in my case it was "magento.bencox.blog". By default on Forge if you SSH in you'll see a directory with all your sites for that server listed.

We now need to install Magento via composer. Before doing so you'll need to do two things. Head over to marketplace.magento.com and create a free account. Once registered you will be able to create API keys, these will be the username and password Magento asks you for when you run the Magento composer install command. You also need to remove the "pub" folder, composer won't let you install Magento in the current directory unless it's an empty folder.

Run the following composer command

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .


After running the composer install you should run the command below. This will set up the correct file permissions for Magento 2.

find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {}\;


Next you will need to change the default NGINX configuration. I have uploaded an example config you can use for your Magento 2 store. You can access this here. Don't forget to replace "magento.bencox.blog" with the URL of your store.

Edit Nginx Configuration

Edit Nginx Configuration


The final step of the process is to edit "/etc/php/7.1/fpm/php.ini", you need to change "cgi.fix_pathinfo=0" to "cgi.fix_pathinfo=1".

You should now be able to access the Magento 2 setup wizard by visiting your domain.