Setting up Laravel with Nginx and phpmyadmin on Ubuntu 14.04

1) Install the Backend Components
1.1) sudo apt-get update
1.2) sudo apt-get upgrade
1.3) sudo apt-get install nginx php5-fpm php5-cli php5-mcrypt git
--------------------------------------------------------------------------------------------------------------------------
2) Modify the PHP Configuration
2.1) sudo nano /etc/php5/fpm/php.ini
2.2) cgi.fix_pathinfo=0 
2.3) sudo php5enmod mcrypt
2.4) sudo service php5-fpm restart
--------------------------------------------------------------------------------------------------------------------------
3) Configure Nginx and the Web Root
3.1) sudo mkdir -p /var/www/laravel
3.2) sudo nano /etc/nginx/sites-available/default


=======================================================
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    #root /var/www/laravel/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

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

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

=======================================================
3.3) sudo service nginx restart
3.4) if you want to setup virtual block
3.4.1) sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
3.4.2) sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

sample for "/etc/nginx/site-availables/example.com
=======================================================
server {
    listen 8080 default_server;
    listen [::]:8080 default_server;

    #root /var/www/laravel_example_com/public;
    index index.php index.html index.htm;

    server_name server_domain_or_IP;

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

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}



======================================================== 

3.4.3) sudo nano /etc/nginx/nginx.conf 
3.4.4) server_names_hash_bucket_size 64; 
3.4.5) sudo service nginx restart 
-------------------------------------------------------------------------------------------------------------------------- 4) Create Swap File (Optional) 4.1) sudo fallocate -l 1G /swapfile 2) sudo mkswap /swapfile 3) sudo swapon /swapfile -------------------------------------------------------------------------------------------------------------------------- 5) Install Composer and Laravel 5.1) cd ~ 5.2) curl -sS https://getcomposer.org/installer | php 5.3) sudo mv composer.phar /usr/local/bin/composer 5.4) sudo composer create-project laravel/laravel /var/www/laravel 5.5) sudo composer create-project laravel/laravel /var/www/laravel 4.2 5.6) sudo chown -R :www-data /var/www/laravel 5.7) sudo chmod -R 775 /var/www/laravel/app/storage 5.8) http://server_domain_or_IP

--------------------------------------------------------------------------------------------------------------------------
4) Install phpmyadmin
4.1) sudo apt-get install phpmyadmin
4.2) che5.ck where is the site
cd /usr/share/nginx/html

4.3) sudo ln  -s /usr/share/phpmyadmin/ /usr/share/nginx/html
it will create a new link name “phpmyadmin” under /user/share/nginx/html
if you want to create custom phpmyadmin link, you can create by the following command
sudo ln  -s /usr/share/phpmyadmin_mycustom_name/ /usr/share/nginx/html
it will create a new link name “phpmyadmin_mycustom_name” under /user/share/nginx/html
And we can call it from browser by “http://ip_address/phpmyadmin; or “http://ip_address/phpmyadmin_mycustom_name;

4.3 ) sudo systemctl restart nginx

—————————————————————————————————————————————-

5) if there is “root /var/www/html” at /etc/nginx/sites-available/default, comment out it
eg ” # root /var/www/html ” and change server_name to
server_name localhost / ip_address;

—————————————————————————————————————————————

6) if “cgi.fix_pathinfo = 0” at /etc/php/7.0/fpm/php.ini, pls change back to original “cgi.fix_pathinfo = 1”
sudo systemctl restart nginx   OR sudo service nginx restart

 

7) If you used the new port for the virtual host, you have to allow that ports to access from globally ( outside )sudo ufw allow 8000/tcp

 

Cheers

 

Laravel Composer Update Issues at Ubuntu

Apache error “Could not reliably determine the server’s fully qualified domain name”

Open a terminal
Open the /etc/apache2/httpd.conf file:
sudo editor /etc/apache2/httpd.conf
By default, it would be blank. Simply add the following line:
ServerName localhost
Save the file and exit
Restart the server
sudo service apache2 restart
=====================================
mbstring is missing while composer updating

– laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.

for general php versions
sudo apt-get install php-mbstring

for php 5.*
sudo apt-get install libapache2-mod-php5

for php 7.*
sudo apt-get install php-mbstring php7.0-mbstring php-gettext libapache2-mod-php7.0

Then, restart apache2:
sudo service apache2 restart ( Ubuntu 14.04 )
sudo systemctl restart apache2 ( Ubuntu 16.04 )

Still missing?

sudo phpenmod mcrypt
sudo phpenmod mbstring

Then, restart apache2
sudo service apache2 restart ( Ubuntu 14.04 )
sudo systemctl restart apache2 ( Ubuntu 16.04 )

===================================

If you got problem, while composer updating
“doctrine-dbal missing”

composer require Doctrine/dbal
or
apt-get install php-doctrine-dbal
=====================================

If you got problem
” phpunit/phpunit 4.8.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.”

for general php versions
sudo apt-get install php-xml

if your php version is 5.*
sudo apt-get install php5.6-xml

if your php version is 7.*
sudo apt-get install php7.0-xml

Sending email with WebMail in laravel 5.2

1) 
===================================================================================
.env
===================================================================================
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:xVpNKIpjAe7LoKTrVd7pKOdJrsaiLmSy8tLYMjerJMS0=
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test_db
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=cpanel1.cloud.com
MAIL_PORT=587
MAIL_USERNAME=test@mywebmaildomain.com
MAIL_PASSWORD=testPassword
MAIL_ENCRYPTION=tls

===================================================================================
config/mail.php
===================================================================================

<?php return [ 'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'cpanel1.cloud.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => ['address' => 'test@mywebmaildomain.com', 'name' => 'Bacekend System'],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'sendmail' => '/usr/sbin/sendmail -bs',
];
===================================================================================

PHP Fatal error: Class’Elibyy\TCPDF\ServiceProvider” in laravel

----------------------------------------------------------------
laravel framework version 5.2 
added at composer.json
 "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "laravelcollective/html": "~5.2",
        "uxweb/sweet-alert": "~1.1",
        "maatwebsite/excel": "~2.1.0",
        "intervention/image": "dev-master",
        "elibyy/tcpdf-laravel": "5.2.*"
    },
------------------------------------------------------------------
1) comment out 2 lines from config/app.php
1.1) at  'providers' => [ 
need to comment out 
//Elibyy\TCPDF\ServiceProvider::class,

1.2) at  'aliases' => [
need to comment out 
//'PDF'       => Elibyy\TCPDF\Facades\TCPDF::class,

------------------------------------------------------------------
2) composer update --no-scripts
3) un-comment previous 2 lines from config/app.php
4) run again "composer update --no-scripts"

Cheers

composer update –no-scripts “Killed” at live server

composer update –no-scripts
has been killed in live server

or

PHP Fatal  error: Uncaught Error: Class ‘Illuminate\Fuoundawtion\Applicationo’ not found in /var/www/server_activation/Bootstrap/app.php:14

 

that case is becasue of not enough memory in live sever. so we need to give the enough memory space to our project

sudo fallocate -l 1G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile