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
#yum install epel-release
# rpm -Uvh https://dl.Fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#yum update
Ubuntu
#apt-get install python-software-properties
# add-apt-repository ppa:ondrej/php5
#apt-get update
#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.
#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
#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.
#systemctl start httpd
#systemctl enable httpd
#systemctl start mysqld
#systemctl enable mysqld
After starting the MariaDB service, you need to run the following command to configure a secure password.
#mysql_secure_installation
Ubuntu
#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.
# curl -sS https://getcomposer.org/installer | php
#mv composer.phar /usr/local/bin/composer
#chmod+x /usr/local/bin/composer
Composer installation
5) install Laravel
Run the following command to download the Laravel installation package from github.
#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.
# unzip develop.zip
#mv laravel-develop /var/www/
Use the compose command to install all the dependencies required by Laravel in the directory.
#cd/var/www/laravel-develop/
# composer install
Compose laravel
6) Key
To encrypt the server, we use the following command to generate an encrypted 32-bit key.
# php artisan key:generate
Application key [Lf54qK56s3qDh0ywgf9JdRxO2N0oV9qI]set successfully
Now put this key in the 'App. php' file, as shown below.
#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.
#chmod775/var/www/laravel-develop/app/storage
#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.
#vim/etc/httpd/conf/httpd.conf
ServerName laravel-develop
DocumentRoot/var/www/laravel/public
start Directory/var/www/laravel
AllowOverrideAll
Directory close
Run the following command to restart the apache server and open the localhost page in the browser.
CentOS
#systemctl restart httpd
Ubuntu
# 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: