Preparing a VPS for Laravel

Getting a Laravel site up and running in a local is just a matter of minutes. However in a production environment, it's a bit more involved. It is not really a hard task per say, but could come to a halt if you forgot one thing along the way like i did the first time through.
So to avoid that kind of misadventure, one need to be thorough and the simplest method is to follow a guide.

The easiest way and the one explained here involve having a VPS at your disposal. If it came with Archlinux or if you choose to be installed with the following will guide your setup step by step.

A server up to date with installed dependencies

It's important to have a nice fully updated system to start on good base with the latest software needed.

sudo pacman -Suy

Now the dependencies we will need to properly setup the server.

sudo pacman -S apache apache-php php-fpm mariadb git npm

With that taking care off, pacman can go rest a little.

PHP side

Some small editing need to be done to config files.

php.ini

Some extensions need to be enabled for Laravel to work properly, those are to be uncommented in the file if needed:

bcmath, bz2, curl, pdo_mysql, zip 

httpd.conf

Some of the default values need some tweaking

  • ServerAdmin: put your own email here (if something go wrong it could reach you better).
  • DocumentRoot: since a Laravel app is served through the public directory, this need to be reflected by changing the root directory line under
/srv/http become /srv/http/appname/public
  • Add the line below to the end of the file to enable php-fpm.conf
Include conf/extra/php-fpm.conf

Last touches

With all the config files edited, the services need to be restarted to take account off the modifications. To do that simply

systemctl restart httpd.service

MySQL side

Less stuff to do on that side

  • Enable the service with:
systemctl enable mysqld
  • Secure the service
mysql_secure_installation
  • Login to leave a comment
    • akrokan
    • I know
    • user
    • This article is incomplete
© 2021 Hugues DATIN