Skip to content

Instantly share code, notes, and snippets.

@lparolari
Last active March 7, 2019 21:26
Show Gist options
  • Save lparolari/42fa216255a5c9fa3e898c3d44409d72 to your computer and use it in GitHub Desktop.
Save lparolari/42fa216255a5c9fa3e898c3d44409d72 to your computer and use it in GitHub Desktop.

Setup Laravel Environment

This reminder shows how to setup an environment for laravel without (intentionally) use a container like docker or a virtual machine like homestead.

Starting from scratch in linux, for setting up a laravel environment we will need first to setup the environment:

  • apache web server: sudo apt install apache2;
  • mysql server: sudo apt install mysql-server;
  • php and extensions: sudo apt install php7.X php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php;
  • you may need to disable mods of older versions of php in apache;
  • enable mod_rewrite: sudo a2enmod rewrite;
  • sqlite: sudo apt-get install php7.2-sqlite3;
  • restart apache: sudo systemctl restart apache2.

Now we need to create a virtual host:

  • create vh directory: sudo mkdir -p /var/www/html/local.dev/public_html;
  • go to apache directory: cd /etc/apache2, cd sites-available;
  • local.dev.conf: sudo cp 000-default.com local.dev.conf, and edit it properly. Remember to add
<Directory /var/www/html/local.dev>
       Options FollowSymLinks Indexes  # needed by our setup.
       AllowOverride All  # needed by laravel routing.
</Directory>
  • enable your site: sudo a2ensite local.dev.conf.

Clone your project with git:

  • (optional) setup ssh keys in order to access your github/gitlab/bitbucket account;
  • clone: git clone your_repo_url;

Setup the symlink from vs document dir to your clone repo:

  • symlink: sudo ln -s /path/to/laravel/project/../public;

Setup file permission (TBD):

  • www-data should be able to read your web dir;
  • writing permission on chache and storage.

Note: this reminded should be completed and revisisted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment