How to install the PHP framework Laravel on CentOS 7/Ubuntu 15.04

Source: Internet
Author: User
Tags mcrypt composer install how to install laravel fully qualified domain name

How to install the PHP framework Laravel on CentOS 7/Ubuntu 15.04

Hello everyone, this article will show you how to install Laravel on CentOS 7/Ubuntu 15.04. If you are a PHP Web Developer, you do not need to consider how to choose from a wide array of modern PHP frameworks. Laravel is the easiest to start and run, saving time and effort, you can enjoy web development. Laravel believes in a universal development philosophy. Using simple guidance to create maintainable code is the highest priority, and you will maintain high development efficiency, you can change your code at any time to improve existing functions.

Laravel installation is not cumbersome. You only need to follow this article to install it on CentOS 7 or Ubuntu 15 servers step by step.

1) server requirements

Before installing Laravel, you need to install some of its dependencies, including basic parameter adjustments, such as upgrading the system to the latest version, sudo permission, and installing dependency packages.

When you connect to your server, make sure that you can use the following command to successfully use the EPEL repository and upgrade your server.

CentOS-7
  1. #yum install epel-release
  2. # rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  3. # rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  4. #yum update
Ubuntu
  1. #apt-get install python-software-properties
  2. # add-apt-repository ppa:ondrej/php5
  3. #apt-get update
  4. #apt-get install -y php5 mcrypt php5-mcrypt php5-gd
2) Firewall Installation

System firewall and SELinux settings are very important for product application security. When you use the test server, you can disable the firewall and use the following command line to set SELinux to permissive) to ensure that the installation programs are not affected by them.

  1. #setenforce0
3) install Apache, MariaDB, and PHP

The Laravel installer needs to complete LAMP installation throughout the environment, and additional PHP extensions such as OpenSSL, PDO, Mbstring, and Tokenizer need to be installed. If LAMP is already running on your server, skip this step and check whether necessary PHP plug-ins are installed.

To install the complete AMP, run the following command on your server.

CentOS
  1. #yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring

To enable Automatic startup of MySQL/Mariadb service on CentOS 7, run the following command.

  1. #systemctl start httpd
  2. #systemctl enable httpd
  3. #systemctl start mysqld
  4. #systemctl enable mysqld

After starting the MariaDB service, you need to run the following command to configure a secure password.

  1. #mysql_secure_installation
Ubuntu
  1. #apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql
4) install Composer

Before installing Laravel, let's start installing composer. Installing composer is one of the most important steps to install Laravel, because composer can help us install various Laravel dependencies.

CentOS/Ubuntu

Run the following command in CentOS/Ubuntu to configure composer.

  1. # curl -sS https://getcomposer.org/installer | php
  2. #mv composer.phar /usr/local/bin/composer
  3. #chmod+x /usr/local/bin/composer

Composer installation

5) install Laravel

Run the following command to download the Laravel installation package from github.

  1. #wget https://github.com/laravel/laravel/archive/develop.zip

Run the following command to decompress the installation package and move the root directory of the document.

  1. # unzip develop.zip
  2. #mv laravel-develop /var/www/

Use the compose command to install all the dependencies required by Laravel in the directory.

  1. #cd/var/www/laravel-develop/
  2. # composer install

Compose laravel

6) Key

To encrypt the server, we use the following command to generate an encrypted 32-bit key.

  1. # php artisan key:generate
  2. Application key [Lf54qK56s3qDh0ywgf9JdRxO2N0oV9qI]set successfully

Now put this key in the 'App. php' file, as shown below.

  1. #vim/var/www/laravel-develop/config/app.php

Key encryption

7) virtual host and user

After the composer is installed, assign the permissions and users of the document root directory, as shown below.

  1. #chmod775/var/www/laravel-develop/app/storage
  2. #chown-R apache:apache /var/www/laravel-develop

Use any editor to open the default configuration file of the apache server, and add the virtual host configuration at the end of the file.

  1. #vim/etc/httpd/conf/httpd.conf
  1. ServerName laravel-develop
  2. DocumentRoot/var/www/laravel/public
  3. start Directory/var/www/laravel
  4. AllowOverrideAll
  5. Directory close

Run the following command to restart the apache server and open the localhost page in the browser.

CentOS
  1. #systemctl restart httpd
Ubuntu
  1. # service apache2 restart
8) Laravel 5 network access

Open your browser and enter the configured IP address or full domain name (Fully qualified domain name). You will see the default page of Laravel 5.

Laravel Default

Summary

The Laravel framework is an excellent tool for developing web applications. So, after reading this article, you will learn to install Laravel on Ubuntu 15 and CentOS 7, then you can use the various functions and comfort of this superb PHP framework for your development work.

If you have any comments or suggestions, please reply in the following comments area. We will make our articles easier to understand based on your valuable feedback.

Deploy Laravel using Nginx in Ubuntu

Deploying Laravel 14.04 using Nginx on Ubuntu 5.0

Via: http://linoxide.com/linux-how-to/install-laravel-php-centos-7-ubuntu-15-04/

Author: kasconditioned Translator: NearTan Proofreader: Caroline

This article was originally compiled by LCTT and launched with the honor of Linux in China

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.