Skip to content

Setup Web with Laravel (PHP 7)

The following setup can be done on a VM or cloud (tested with 1&1 cloud). It assumes that there already is php, nginx... installed there.

It will install everything that's needed to run Laravel.

Reference

https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

PHP 7

As root:

yum remove php-fpm php-cli php-common
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y yum-utils
yum-config-manager --disable remi-php72
yum-config-manager --disable remi-php73
yum-config-manager --enable remi-php71
yum install php php-fpm php-opcache php-cli php-zip -y
php70u-json ???

Config:

vi /etc/php-fpm.d/www.conf
vi /etc/nginx/default.d/php.conf
listen=/run/php-fpm/www.sock
listen.acl_user=nginx
systemctl restart php-fpm
systemctl restart nginx

Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php --ini
vi /etc/php.ini
php -m
grep 'extension=' /etc/php.ini
sudo vi /etc/php.ini
php composer-setup.php
sudo vi /etc/php.ini
php composer-setup.php
ls -al
sudo cp composer.phar /usr/local/bin/composer
ls -la

Laravel

composer global require "laravel/installer"

sudo yum install php-mbstring php-dom php-pgsql -y

laravel new mission

PostgreSQL

sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
sudo yum install postgresql96-server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
sudo systemctl enable postgresql-9.6.service
sudo systemctl start postgresql-9.6.service
sudo su - postgres
psql postgres -c "CREATE USER app PASSWORD 'myapp' CREATEDB"
exit
psql postgres -c "CREATE DATABASE mission"

Other

sudo chgrp -R php-fpm storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache