Setting up a Laravel server

6 years ago
2 min read


Create droplet and link domain

❑  Create a droplet via Digital Ocean ($100 credit for new members link 🔥).
❑  Add your SSH key when creating your droplet.
❑  Add your domain name in the “Networking” section.
❑  Points @ to the newly created droplet.

Make bash more friendly

❑  ssh root@IPADDRESS
❑  vim ~/.bashrc → search /force_color_prompt → uncomment
❑  vim ~/.bashrc → search /PS1 → remove @\h and \w becomes \W
❑  Reload shell exec bash -l

Add locales

❑  echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale
locale-gen en_US.UTF-8
❑  exit and reconnect ssh root@IPADDRESS

Install php 7.2

❑  apt-get update -y && apt-get upgrade -y
❑  apt-get -y install python-software-properties
❑  add-apt-repository -y ppa:ondrej/php
❑  apt-get update -y
❑  apt-get -y install php7.2 php7.2-common php7.2-gd php7.2-intl php7.2-zip php7.2-sqlite3 php7.2-mysql php7.2-fpm php7.2-mbstring php7.2-xml php7.2-curl php7.2-memcached unzip zip composer

Configure your ngnix server

server {
    listen 80;
    listen [::]:80 ipv6only=on;
    root /var/www/;
    index index.html index.htm index.php;

    charset utf-8;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    location / {
        try_files $uri $uri/ /index.php?$query_string;

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/ error;

    error_page 404 /index.php;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;

    location ~ /\.ht {
        deny all;

❑  service nginx restart && service php7.2-fpm reload

Set up mysql and create a database

❑  cat /root/.digitalocean_password
❑  mysql_secure_installation
❑  mysql -uroot -p -e "create database laravel;"


Would you like to chime in?

You must be a member to start a new discussion.

Fortunately, it only takes two click to become one. See you on the other side! 🌸

Become a Member