How to Install Laravel PHP Framework on CentOS
To install Laravel PHP Framework on CentOS
Laravel is an open source PHP framework for Linux distributions. It enables the users to develop the MVC web applications in PHP. Installation of Laravel PHP Framework in CentOS is discussed in this article.
Installation of Laravel PHP Framework
Setup the repository file to download the latest version of the PHP.
[root@linuxhelp1 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm warning: /var/tmp/rpm-tmp.thvHiY: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:epel-release-7-8 ################################# [100%] [root@linuxhelp1 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm warning: /var/tmp/rpm-tmp.pMgscS: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:webtatic-release-7-3 ################################# [100%]
Now install the php packages that are need for installing the laravel.
[root@linuxhelp1 ~]# yum install php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring -y
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
epel/x86_64/metalink | 4.1 kB 00:00
epel | 4.3 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
webtatic | 3.6 kB 00:00
(1/7): epel/x86_64/group_gz | 170 kB 00:01
(2/7): webtatic/x86_64/group_gz | 448 B 00:02
(3/7): extras/7/x86_64/primary_db | 160 kB 00:04
(4/7): webtatic/x86_64/primary_db | 129 kB 00:03
(5/7): epel/x86_64/updateinfo | 623 kB 00:08
(6/7): epel/x86_64/primary_db | 4.2 MB 00:15
(7/7): updates/7/x86_64/primary_db | 7.1 MB 02:37
Determining fastest mirrors
* base: centos.webwerks.com
* epel: epel.mirror.net.in
* extras: centos.webwerks.com
* updates: centos.webwerks.com
* webtatic: sp.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package php56w.x86_64 0:5.6.25-1.w7 will be installed
--> Processing Dependency: php56w-common(x86-64) = 5.6.25-1.w7 for package: php56w-5.6.25-1.w7.x86_64
--> Processing Dependency: php56w-cli(x86-64) = 5.6.25-1.w7 for package: php56w-5.6.25-1.w7.x86_64
--> Processing Dependency: php56w-cli = 5.6.25-1.w7 for package: php56w-5.6.25-1.w7.x86_64
--> Processing Dependency: httpd-mmn = 20120211x8664 for package: php56w-5.6.25-1.w7.x86_64
.
.
.
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7
apr-util.x86_64 0:1.5.2-6.el7
httpd.x86_64 0:2.4.6-40.el7.centos.4
httpd-tools.x86_64 0:2.4.6-40.el7.centos.4
libmcrypt.x86_64 0:2.5.8-13.el7
mailcap.noarch 0:2.1.41-2.el7
php56w-cli.x86_64 0:5.6.25-1.w7
php56w-common.x86_64 0:5.6.25-1.w7
php56w-pdo.x86_64 0:5.6.25-1.w7
Complete!
Next install the Apache and Mariadb by using the below command.
[root@linuxhelp1 ~]# yum install httpd mariadb mariadb-server -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirror01.idc.hinet.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
* webtatic: sp.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
---> Package mariadb.x86_64 1:5.5.50-1.el7_2 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.50-1.el7_2 for package: 1:mariadb-5.5.50-1.el7_2.x86_64
---> Package mariadb-server.x86_64 1:5.5.50-1.el7_2 will be installed
.
.
.
Installed:
httpd.x86_64 0:2.4.6-40.el7.centos.4 mariadb.x86_64 1:5.5.50-1.el7_2
mariadb-server.x86_64 1:5.5.50-1.el7_2
Dependency Installed:
perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7
perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBD-MySQL.x86_64 0:4.023-5.el7
perl-DBI.x86_64 0:1.627-4.el7
perl-Data-Dumper.x86_64 0:2.145-3.el7
perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7
Dependency Updated:
mariadb-libs.x86_64 1:5.5.50-1.el7_2
Complete!
Now you need to start and enable the Apache and Mariadb.
[root@linuxhelp1 ~]# systemctl start httpd.service
[root@linuxhelp1 ~]# systemctl start mariadb.service
[root@linuxhelp1 ~]# systemctl enable httpd.service
ln -s ' /usr/lib/systemd/system/httpd.service' ' /etc/systemd/system/multi-user.target.wants/httpd.service'
[root@linuxhelp1 ~]# systemctl enable mariadb.service
ln -s ' /usr/lib/systemd/system/mariadb.service' ' /etc/systemd/system/multi-user.target.wants/mariadb.service'
Run the below command to install the composer, which is required for installing Laravel dependencies.
[root@linuxhelp1 ~]# curl -sS https://getcomposer.org/installer | php
All settings correct for using Composer
Downloading 1.2.0...
Composer successfully installed to: /root/composer.phar
Use it: php composer.phar
Move the composer to their respective directory and give executable permission.
[root@linuxhelp1 ~]# mv composer.phar /usr/local/bin/composer
[root@linuxhelp1 ~]# chmod +x /usr/local/bin/composer
Now you need to clone master repo of laravel from the github. For that install the git with the below given command.
[root@linuxhelp1 ~]# yum install git -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirror01.idc.hinet.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
* webtatic: sp.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-6.el7_2.1 for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Running transaction check
.
.
.
Installed:
git.x86_64 0:1.8.3.1-6.el7_2.1
Dependency Installed:
perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-6.el7_2.1
perl-TermReadKey.x86_64 0:2.30-20.el7
Complete!
Then move the git to the document root directory. Now start download the laravel.
[root@linuxhelp1 ~]# cd /var/www/
[root@linuxhelp1 www]# git clone https://github.com/laravel/laravel.git
Cloning into ' laravel' ...
remote: Counting objects: 27333, done.
remote: Total 27333 (delta 0), reused 0 (delta 0), pack-reused 27333
Receiving objects: 100% (27333/27333), 7.63 MiB | 44.00 KiB/s, done.
Resolving deltas: 100% (16624/16624), done.
Navigate to Laravel code directory and use the composer to install all the required dependencies of Laravel framework.
[root@linuxhelp1 www]# cd laravel/
[root@linuxhelp1 laravel]# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing vlucas/phpdotenv (v2.4.0)
Downloading: 100%
- Installing symfony/polyfill-mbstring (v1.2.0)
Downloading: 100%
- Installing symfony/var-dumper (v3.1.4)
Downloading: 100%
- Installing symfony/translation (v3.1.4)
Downloading: 100%
- Installing symfony/routing (v3.1.4)
Downloading: 100%
.
.
.
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (> =2.4.0)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
> IlluminateFoundationComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
Compiling common classes
Set proper permissions on files with the following command.
[root@linuxhelp1 laravel]# chown -R apache.apache /var/www/laravel
[root@linuxhelp1 laravel]# chmod -R 755 /var/www/laravel
Also set the encryption key before that change the name of the file.
[root@linuxhelp1 laravel]# mv .env.example .env
[root@linuxhelp1 laravel]# php artisan key:generate
Application key [base64:KR78ySV1xBZ1es9T3/ZMGzs+K0rCOSf6XGsUkKtBZp8=] set successfully.
Here you need to copy the generated key to the app.php as given below.
[root@linuxhelp1 laravel]# cd config/
[root@linuxhelp1 config]# vi app.php
' key' => env(' APP_KEY' , ' base64:KR78ySV1xBZ1es9T3/ZMGzs+K0rCOSf6XGsUkKtBZp8=' ),
' cipher' => ' AES-256-CBC' ,
Now its time to create virtual hosting by using the below command. Virtual Host is added in Apache configuration file to access Laravel framework from web browser.
[root@linuxhelp1 config]# vim /etc/httpd/conf/httpd.conf
< VirtualHost *:80>
ServerName www.linuxhelp1.com.com
DocumentRoot /var/www/laravel/public
< Directory /var/www/laravel>
AllowOverride All
Require all granted
< /Directory>
< /VirtualHost>
Finally, restart Apache service with following command to access the Laravel framework.
[root@linuxhelp1 config]# systemctl restart httpd
Now you can access the Laravel in browser. Enter ip address or domain name to develop a great web application in PHP.
Comments ( 0 )
No comments available