Skip to content

Installation on Linux

Maxim Drachinskiy edited this page Jun 12, 2017 · 22 revisions

Requirements

  • MySQL Database

  • Apache Server

  • in httpd.conf, uncomment rewrite module: LoadModule rewrite_module modules/mod_rewrite.so

  • then uncomment MySQL extensions: extension=php_pdo_mysql.so, extension=mysqli.so

  • PHP >= 5.6.4

  • OpenSSL PHP Extension

  • PDO PHP Extension

  • Mbstring PHP Extension

  • Tokenizer PHP Extension

  • XML PHP Extension

  • Composer

  • Laravel Framework is already included in this repository.

Installation on a CentOS production server

"$>" stands for console commands

  1. Install the server, e.g.: $> yum install httpd mariadb-server php php-ldap php-mysql

  2. Install Composer:

    • open directory: $> cd /usr/local/bin/
    • download composer: $> php -r "readfile('https://getcomposer.org/installer');" | php
    • add a symbolic link: $> ln –s /usr/local/bin/composer.phar /usr/local/bin/composer.
  3. Install git: $> yum install git

  4. Copy Lara files with git:

    • open directory: $> cd /var/www/
    • clone repository with git: $> git clone https://github.com/ILSCeV/Lara.git
  5. Update dependencies: $> composer install (this one can take some time - don't worry, make some tea)

  6. Change permissions:

    • $> cd /var/www
    • $> chown -R apache:apache Lara/
    • $> chmod -R 755 Lara/
    • $> chmod -R 777 Lara/storage
    • $> chmod -R 777 Lara/bootstrap/cache
  7. To hide "/Lara/public" path:

    • open the Apache Server config (actual filename may vary): $> vi /etc/httpd/conf.d/httpd.conf
    • type i to enter editing mode
    • change DocumentRoot to DocumentRoot "var/www/Lara/public"
    • hit <ESC> to exit editing mode
    • type :x and hit <Return> to exit vi
  8. Restart the server: $> /etc/init.d/httpd restart

  9. Create a MySQL database named "lara":

    • switch to MySQL: $> mysql –u root –p
    • create new database named "lara": $> create database lara
    • update database schema from /Lara/ folder: $> php artisan migrate --seed
    • (Skip this step if you are using an existing production DB or you will overwrite the data.)
  10. Rename the file .env.example located in /var/www/Lara/ into .env and edit environment variables:

    • set "APP_ENV=production" (or e.g. "development" depending on your context)
      • For development purposes a workaround is built into the LoginController which assigns a random dummy-user at each login event, ignoring login/password input from user. It's activated if the "APP_ENV"-variable is set to "development".
    • set "APP_DEBUG=false" (or "true" for development)
    • set a new application key with $> php artisan key:generate
    • set "DB_HOST", "DB_DATABASE", "DB_USERNAME" and "DB_PASSWORD" to your database credentials
  11. For development only: Install Node (https://nodejs.org/en/) then run (in the /Lara/ directory):

    • $> npm install
    • $> npm run dev
    • This will install typescript and other dependencies. npm run dev is used to build the JS/TS files from the resources directory to the public directory.
  12. Run this once: $> php artisan config:cache

  13. To support task scheduling, a cronjob should be added to /etc/crontab, and execute in the name of the server ("apache") to prevent disowning log files:

  • * * * * * apache php /path/to/your/Lara/folder/artisan schedule:run >> /dev/null 2>&1
  • Restart the service: $> /etc/init.d/crond restart

Installation an an Arch-Linux - based system

  1. # pacman -S php php-fpm composer npm mariadb nginx git

  2. Copy Lara files with git:

    • open directory: $> cd /srv/http/
    • clone repository with git: # git clone https://github.com/ILSCeV/Lara.git
  3. Update dependencies: $> composer install (this one can take some time - don't worry, make some tea)

  4. Change permissions:

    • $> cd /srv/http/
    • $> chown -R http:http Lara/
    • $> chmod -R 755 Lara/
    • $> chmod -R 777 Lara/storage
    • $> chmod -R 777 Lara/bootstrap/cache
  5. Edit /etc/nginx/nginx.conf

http{
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /srv/http/Lara/public;
        index index.php index.html index.htm;

        location / {
        try_files $uri $uri/ /index.php?$query_string;
        }
        # Remove trailing slash to please routing system.
        if (!-d $request_filename) {
            rewrite     ^/(.+)/$ /$1 permanent;
        }
        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
            }
    }
}
  1. Configure Database
  • uncomment MySQL extensions in /etc/php/php.ini: extension=php_pdo_mysql.so, extension=mysqli.so
  • # mysql_secure_installation
  • # systemctl start mysqld
  • # systemctl enable mysqld
  1. Create a MySQL database named "lara":
    • switch to MySQL: $> mysql –u root –p
    • create new database named "lara": $> create database lara
    • update database schema from /Lara/ folder: $> php artisan migrate --seed
    • (Skip this step if you are using an existing production DB or you will overwrite the data.)
  2. For development only:
    • $> npm install
    • $> npm run dev
    • This will install typescript and gulp and running gulp will compile the typescript sources to the bundle.js file in /public/bin/. Note that installing all dependencies may take a while but you can already proceed with the next steps.
  3. start the http server
  • systemctl start nginx
  • systemctl enable nginx
  1. Run this once: $> php artisan config:cache

  2. To support task scheduling, a cronjob should be added to /etc/crontab:

  • * * * * * http php /path/to/your/Lara/folder/artisan schedule:run >> /dev/null 2>&1
  • Restart the service: $> /etc/init.d/crond restart