AMP AMP

How to Create a Project in Laravel 5.8.33 on CentOS 7.6

Creation of Laravel Project On CentOS 7.6

Laravel Framework is a free and open-source web application framework for building high-end applications. It comes with a strong collection of tools and provides application architecture where it includes various characteristics of technologies like ASP.NET MVC, codeIgniter, Ruby on Rails. It facilitates developers by saving huge time and helps reduce thinking and planning to develop the entire website from scratch. This video explains the method to create the project in Laravel 8.5.33 on CentOS 7.6

Pre-requisites:

LAMP Stack :

Apache 2.4.6

MariaDB 5.5

PHP 7.2

Composer ----> To Install laravel Dependencies

PHP Modules:

Php php-pecl-zip php-mysql php-mcrypt php-xml php-mbstring

Command To Create the Laravel project

composer create-project --prefer-dist laravel/laravel <projectname>

LAMP Stack version verification

Check the versions of php,mariaDB and Apache as follows.

[root@linuxhelp ~]# php -v
PHP 7.2.17 (cli) (built: Apr  3 2019 10:02:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@linuxhelp ~]# mysql -V
mysql  Ver 15.1 Distrib 5.5.60-MariaDB, for Linux (x86_64) using readline 5.1
[root@linuxhelp ~]# httpd -V
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09

Install Composer to install the laravel dependencies

[root@linuxhelp ~]#  curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading...

Composer (version 1.9.0) successfully installed to: /root/composer.phar
Use it: php composer.phar

Rename the Composer php.archive to the /usr/local/bin location.

[root@linuxhelp ~]# mv composer.phar /usr/local/bin/composer

Assigning the Executing permission to the composer file

[root@linuxhelp ~]# chmod +x /usr/local/bin/composer

Laravel Project Creation process

Naviagate ot the Apache’s Document Root Directory

[root@linuxhelp ~]# cd /var/www

Create the laravel project using composer as follows

[root@linuxhelp www]# composer create-project --prefer-dist laravel/laravel linuxhelp1
Installing laravel/laravel (v5.8.17)
  - Installing laravel/laravel (v5.8.17): Downloading (100%)         
Created project in linuxhelp1
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 80 installs, 0 updates, 0 removals
  - Installing symfony/polyfill-ctype (v1.12.0): Downloading (100%)         
  - Installing phpoption/phpoption (1.5.0): Downloading (100%)         
  - Installing vlucas/phpdotenv (v3.4.0): Downloading (100%)         
.
.
.
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

List the directories inside the www directory to verify the created project

[root@linuxhelp www]# ls -la
total 8
drwxr-xr-x   5 root root   51 Aug 22 12:08 .
drwxr-xr-x. 22 root root 4096 Apr 15 10:40 ..
drwxr-xr-x   2 root root    6 Nov  5  2018 cgi-bin
drwxr-xr-x   2 root root   22 Apr 15 11:10 html
drwxr-xr-x  12 root root 4096 Aug 22 12:11 linuxhelp1

Change the directory to linuxhelp1

[root@linuxhelp www]# cd linuxhelp1/

List the directories inside the linuxhelp1 project

[root@linuxhelp linuxhelp1]# ls -la
total 228
drwxr-xr-x 12 root root   4096 Aug 22 12:11 .
drwxr-xr-x  5 root root     51 Aug 22 12:08 ..
drwxr-xr-x  6 root root     84 May 14 18:58 app
-rwxr-xr-x  1 root root   1686 May 14 18:58 artisan
drwxr-xr-x  3 root root     34 May 14 18:58 bootstrap
-rw-r--r--  1 root root   1550 May 14 18:58 composer.json
-rw-r--r--  1 root root 167767 Aug 22 12:11 composer.lock
drwxr-xr-x  2 root root    247 May 14 18:58 config
drwxr-xr-x  5 root root     72 May 14 18:58 database
-rw-r--r--  1 root root    213 May 14 18:58 .editorconfig
-rw-r--r--  1 root root    790 Aug 22 12:11 .env
-rw-r--r--  1 root root    739 May 14 18:58 .env.example
-rw-r--r--  1 root root    111 May 14 18:58 .gitattributes
-rw-r--r--  1 root root    151 May 14 18:58 .gitignore
-rw-r--r--  1 root root   1125 May 14 18:58 package.json
-rw-r--r--  1 root root   1156 May 14 18:58 phpunit.xml
drwxr-xr-x  4 root root    116 May 14 18:58 public
-rw-r--r--  1 root root   4151 May 14 18:58 readme.md
drwxr-xr-x  6 root root     53 May 14 18:58 resources
drwxr-xr-x  2 root root     75 May 14 18:58 routes
-rw-r--r--  1 root root    563 May 14 18:58 server.php
drwxr-xr-x  5 root root     46 May 14 18:58 storage
-rw-r--r--  1 root root    174 May 14 18:58 .data-styleci.yml
drwxr-xr-x  4 root root     83 May 14 18:58 tests
drwxr-xr-x 40 root root   4096 Aug 22 12:11 vendor
-rw-r--r--  1 root root    538 May 14 18:58 webpack.mix.js

Assign Ownership and Writable permissions to the linuxhelp1 project recursively.

[root@linuxhelp linuxhelp1]# chown -R apache. .
[root@linuxhelp linuxhelp1]# chmod -R 775 .

Verify the permissions assigned to the files and directories of LinuxHelp1 project as follows

[root@linuxhelp linuxhelp1]# ls -la
total 228
drwxrwxr-x 12 apache apache   4096 Aug 22 12:11 .
drwxr-xr-x  5 root   root       51 Aug 22 12:08 ..
drwxrwxr-x  6 apache apache     84 May 14 18:58 app
-rwxrwxr-x  1 apache apache   1686 May 14 18:58 artisan
drwxrwxr-x  3 apache apache     34 May 14 18:58 bootstrap
-rwxrwxr-x  1 apache apache   1550 May 14 18:58 composer.json
-rwxrwxr-x  1 apache apache 167767 Aug 22 12:11 composer.lock
drwxrwxr-x  2 apache apache    247 May 14 18:58 config
drwxrwxr-x  5 apache apache     72 May 14 18:58 database
-rwxrwxr-x  1 apache apache    213 May 14 18:58 .editorconfig
-rwxrwxr-x  1 apache apache    790 Aug 22 12:11 .env
-rwxrwxr-x  1 apache apache    739 May 14 18:58 .env.example
-rwxrwxr-x  1 apache apache    111 May 14 18:58 .gitattributes
-rwxrwxr-x  1 apache apache    151 May 14 18:58 .gitignore
-rwxrwxr-x  1 apache apache   1125 May 14 18:58 package.json
-rwxrwxr-x  1 apache apache   1156 May 14 18:58 phpunit.xml
drwxrwxr-x  4 apache apache    116 May 14 18:58 public
-rwxrwxr-x  1 apache apache   4151 May 14 18:58 readme.md
drwxrwxr-x  6 apache apache     53 May 14 18:58 resources
drwxrwxr-x  2 apache apache     75 May 14 18:58 routes
-rwxrwxr-x  1 apache apache    563 May 14 18:58 server.php
drwxrwxr-x  5 apache apache     46 May 14 18:58 storage
-rwxrwxr-x  1 apache apache    174 May 14 18:58 .data-styleci.yml
drwxrwxr-x  4 apache apache     83 May 14 18:58 tests
drwxrwxr-x 40 apache apache   4096 Aug 22 12:11 vendor
-rwxrwxr-x  1 apache apache    538 May 14 18:58 webpack.mix.js

Navigate to the public directory to view the index file by listing it as follwos

[root@linuxhelp linuxhelp1]# cd public/
[root@linuxhelp public]# ls -la
total 20
drwxrwxr-x  4 apache apache  116 May 14 18:58 .
drwxrwxr-x 12 apache apache 4096 Aug 22 12:11 ..
drwxrwxr-x  2 apache apache   21 May 14 18:58 css
-rwxrwxr-x  1 apache apache    0 May 14 18:58 favicon.ico
-rwxrwxr-x  1 apache apache  593 May 14 18:58 .htaccess
-rwxrwxr-x  1 apache apache 1823 May 14 18:58 index.php
drwxrwxr-x  2 apache apache   20 May 14 18:58 js
-rwxrwxr-x  1 apache apache   24 May 14 18:58 robots.txt
-rwxrwxr-x  1 apache apache 1194 May 14 18:58 web.config

Navigate to the Apache Configuration File

[root@linuxhelp public]# cd /etc/httpd/conf.d/

Create a virtual host for linuxhelp1 Project as follows

[root@linuxhelp conf.d]# vim linuxhelp1.conf
<virtualhost *:80>
servername www.linuxhelp1.com
documentroot /var/www/linuxhelp1/public/
</virtualhost>

Restart the service of Apache

[root@linuxhelp conf.d]# systemctl restart httpd

Open the Browser and enter the server name that has configured inside the linuxhelp1 virtual host

To check the version of laravel, use the following command.

Navigate to the LinuxHelp project location

[root@linuxhelp ~]# cd /var/www/linuxhelp1/

List the directories of project

[root@linuxhelp linuxhelp1]# ls -la
total 228
drwxrwxr-x 12 apache apache   4096 Aug 22 12:11 .
drwxr-xr-x  5 root   root       51 Aug 22 12:08 ..
drwxrwxr-x  6 apache apache     84 May 14 18:58 app
-rwxrwxr-x  1 apache apache   1686 May 14 18:58 artisan
drwxrwxr-x  3 apache apache     34 May 14 18:58 bootstrap
-rwxrwxr-x  1 apache apache   1550 May 14 18:58 composer.json
-rwxrwxr-x  1 apache apache 167767 Aug 22 12:11 composer.lock
drwxrwxr-x  2 apache apache    247 May 14 18:58 config
drwxrwxr-x  5 apache apache     72 May 14 18:58 database
-rwxrwxr-x  1 apache apache    213 May 14 18:58 .editorconfig
-rwxrwxr-x  1 apache apache    790 Aug 22 12:11 .env
-rwxrwxr-x  1 apache apache    739 May 14 18:58 .env.example
-rwxrwxr-x  1 apache apache    111 May 14 18:58 .gitattributes
-rwxrwxr-x  1 apache apache    151 May 14 18:58 .gitignore
-rwxrwxr-x  1 apache apache   1125 May 14 18:58 package.json
-rwxrwxr-x  1 apache apache   1156 May 14 18:58 phpunit.xml
drwxrwxr-x  4 apache apache    116 May 14 18:58 public
-rwxrwxr-x  1 apache apache   4151 May 14 18:58 readme.md
drwxrwxr-x  6 apache apache     53 May 14 18:58 resources
drwxrwxr-x  2 apache apache     75 May 14 18:58 routes
-rwxrwxr-x  1 apache apache    563 May 14 18:58 server.php
drwxrwxr-x  5 apache apache     46 May 14 18:58 storage
-rwxrwxr-x  1 apache apache    174 May 14 18:58 .data-styleci.yml
drwxrwxr-x  4 apache apache     83 May 14 18:58 tests
drwxrwxr-x 40 apache apache   4096 Aug 22 12:11 vendor
-rwxrwxr-x  1 apache apache    538 May 14 18:58 webpack.mix.js

Now check the version of Laravel using Artisan File

[root@linuxhelp linuxhelp1]# php artisan --version
Laravel Framework 5.8.33

With this.Creation of Project In Laravel 5.8.33 On CentOS 7.6

Tag : Laravel CentOS
FAQ
Q
What does Public Directory Contain in Laravel Application?
A
In Laravel Application, Public Directory Contains index.php file and also it holds the compiled assets.
Q
What does the vendor directory contain in Laravel Application?
A
In Laravel Application, Vendor Directory contains all the dependency packages installed with composer.
Q
What is composed used for in Laravel Installation?
A
Composer is a package manager and also dependency manager which supports in the installation of laravel dependencies.
Q
What is an Application Framework?
A
The application framework is a software library providing a fundamental structure to support the development of applications. Laravel is an application framework.
Q
What is Laravel?
A
Laravel is a free and open-source php framework to build high-end web applications.