Setup Production DB Server: MariaDB + PhpMyAdmin

Standard

Update Centos:

sudo yum update
sudo yum install nano wget

DB Server

sudo yum install httpd php php-mysql

sudo service httpd start
sudo systemctl enable httpd

Install MariaDB
Add MariaDB Repo

sudo nano /etc/yum.repos.d/MariaDB.repo

Put this inside MariaDB.repo


# MariaDB 10.1 CentOS repository list - created 2016-06-07 15:06 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Install and Start Maria DB

sudo yum install MariaDB-server MariaDB-client

sudo service mariadb start
sudo systemctl enable mariadb

Securing Maria DB

sudo /usr/bin/mysql_secure_installation

Installing PHP MyAdmin

sudo yum install epel-release

sudo yum install phpmyadmin

PhpMyadmin Configuration

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Change Php MyAdmin URL

Alias /NePhpMyAdminUrl /usr/share/phpMyAdmin

To allow access from All add Require all granted

<RequireAny>
   Require all granted
   Require ip 127.0.0.1
   Require ip ::1
</RequireAny>

Restart Web Server

sudo service httpd restart

URL

http://domain.com/NePhpMyAdminUrl

Setup IP Address and Network Connection on CENTOS 7

Standard

Edit ifcfg file

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Add this

TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=62f47c6d-cf65-409f-bbd6-696db494d74c
DEVICE=eth0
ONBOOT=yes
IPADDR=73.123.136.53
NETMASK=255.255.255.248
GATEWAY=73.123.136.49
DNS1=8.8.8.8
DNS2=8.8.4.4

And then run command

service network restart

ping google.com

[SOLVED] Laravel 5.1 Nginx/Apache: Can’t display errors, 500 internal server error

Standard

Edit index.php in public folder.

put all code inside try .. catch …


<?php

try {

require __DIR__.'/../bootstrap/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
	$request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);


} catch(\Exception $e) {
    echo "<pre>";
    echo $e;
    echo "</pre>";
}

[Solved] Laravel Storage Permission Denied even chmod 777

Standard

By default, SELinux will block the ability for Apache/webapps to write to files in RHEL/Centos. This is a security feature to limit what folders Apache can write to. You can notice this issue if you get errors in your Apache/Nginx such as:

PHP Warning:  move_uploaded_file(): Unable to move ‘/path/to/upload/…’ to ‘…….’

Command to set permissions:

chcon -R -t httpd_sys_rw_content_t <folder_name>

You can check the SELinux permissions via the following command:

ls -halZ

If You get Laravel Storage Permission Denied even chmod 777 there is posibility it is caused by SELinux mode in the server. SELinux was enabled which prevent Apache/Nginx to write files even with 777 mode.

Check

 sudo setenforce 0

This should allow writing to storage directory, If permission denied gone, this prove SELinux is the problem. Turn SELinux back

setenforce 1

Then finally use SELinux to allow writing of the file by using this command

chcon -R -t httpd_sys_rw_content_t storage

And you’re off!