Laravel

Extranet >> Websites >> Laravel

Placeholder voor Laravel gerelateerd materiaal

Lumen

installatie: composer create-project –prefer-dist laravel/lumen ‘directory-name-and-sitename’
secure headers: composer require bepsvpt/secure-headers
cookie authentication: composer require illuminate/cookie
session handling: composer require illuminate/session
table column modifications: composer require doctrine/dbal

Deploy script

#!/bin/bash

USER='michiel'
GROUP='www-data'

echo "Clean up old mess"
#rm -rf node_modules
rm -rf vendor
rm -rf public/css public/images public/js public/fonts public/webfonts

# adjust all permissions
echo "Adjusting file permissions"
sudo find ./ -type f -exec chown $USER.$GROUP {} \;
sudo find ./ -type f -exec chmod 664 {} \;

echo "Adjusting directory permissions"
sudo find ./ -type d -exec chown $USER.$GROUP {} \;
sudo find ./ -type d -exec chmod 775 {} \;

echo "Setting sticky bit"
sudo chmod 2775 bootstrap/cache
sudo find ./storage -type d -exec chmod 2775 {} \;

echo "Make stuff executable"
chmod u+x artisan
chmod u+x deploy

# no NPM modules in lumen backend server
# install/require all modules
#echo "Installing NPM modules"
#npm install
#chmod u+x node_modules/.bin/*

# recreate the autoloader files for production
echo "Installing composer modules"
composer install --optimize-autoloader --no-dev

echo "Clearing caches"
./artisan config:cache
./artisan view:cache

echo "Optimizing files"
./artisan package:discover
./artisan optimize

# route cache can be used for projects using only controller routes
# and no closures
# php artisan route:cache

# no need to run NPM on a lumen backend server
#echo "Creating application files"
#npm run production

# and update the database
echo "Updating the database"
./artisan migrate

# no queue implementation (yet)
#echo "restarting the queue"
#./artisan queue:restart

# remove the node_modules, we should not be needing those anymore
#echo "final cleanup, removing node_modules"
#rm -rf node_modules

Apache conf

<VirtualHost *:80>
        ServerName <hostname>
        DocumentRoot <dir-to-public>
        CustomLog /var/log/apache2/<acces-log-name>.log combined
        DirectoryIndex index.html index.php

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =<hostname>
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName <hostname>
        DocumentRoot <dir-to-public>

        Include /etc/apache2/snippets/basic.conf
        Header always set X-Frame-Options "deny"
        
#        Header always set Content-Security-Policy "default-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src *;frame-src 'self'; font-src *; connect-src 'self'"

        <FilesMatch \.php$>
            # Apache 2.4.10+ can proxy to unix socket
            SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
        </FilesMatch>

        <Directory <dir-to-public> >
            Options Indexes FollowSymLinks
            AllowOverride all
            Require all granted
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/<error-log-name>.log
        CustomLog ${APACHE_LOG_DIR}/<access-log-name>.log combined
        
        Include /etc/apache2/snippets/options-ssl-apache.conf

        
	SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
	SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</VirtualHost>