Manual La Ravel
Manual La Ravel
1 on CentOS 7
English | Deutsch Log in or Sign up
Tutorial search
Tutorials How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Ad Scan your Web-Server for Malware with ISPProtect now. Get Free Trial.
How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Laravel is an open source PHP framework that follows the MVC (Model-
On this page
View-Controller) design pattern. It has been created by Taylor Otwell in
2011 as an attempt to provide an advanced alternative to the CodeIgniter
Step 1 - Install the EPEL Repository
(CI) framework. In 2011, the Laravel project released version 1 and 2, this
Step 2 - Install Nginx
year version 5.4 has been released with many improvements like
Step 3 - Install and Configure PHP-FPM 7.1
Command-Line (CLI) support named 'artisan', built-in support for more
Step 4 - Install MariaDB Server
database types and improved routing.
Step 5 - Install PHP Composer
Step 6 - Configure Nginx Virtual Host for Laravel
In this tutorial, I will show you how to install the Laravel Web Framework Step 7 - Install Laravel
with Nginx web server, PHP-FPM 7.1 and MariaDB on a CentOS 7 Step 8 - Configure SELinux
system. I will show you step by step how to install and configure Laravel Step 9 - Testing Laravel
under the LEMP stack on CentOS 7 server. Reference
Prerequisite:
CentOS 7 Server.
Root Privileges.
EPEL or Extra Package for Enterprise Linux is an additional package repository that provides useful software packages that are not included in
the CentOS official repository. It can be installed on RPM based Linux distributions like CentOS and Fedora.
In this tutorial, we need the EPEL repository for the Nginx installation as Nginx packages
do not exist in the official CentOS repository. Install the EPEL repository with the yum
command below.
In this tutorial, we will run a Laravel under the LEMP Stack. Nginx is the web server part of
the LEMP stack and can be installed from EPEL repository.
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 1/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
When the installation is complete, start Nginx and add it to start at boot time.
Nginx is running on port 80, check it with the netstat command below.
netstat -plntu
In case you get 'Command not found' as result, then install the net-tools package as shown below.
Laravel can be installed on a server with PHP version >= 5.6.4. In this tutorial, we will use the latest version PHP 7.1 that is supported by
Laravel.
PHP 7.1 does not exist in the CentOS base repository, we need to install it from a third party repository named 'webtatic'.
Now we can install PHP-FPM with all of the extensions needed by Laravel with a single yum command.
yum install -y php71w php71w-curl php71w-common php71w-cli php71w-mysql php71w-mbstring php71w-fpm php71w-xml php71w-pdo
php71w-zip
Next, configure PHP by editing the configuration file php.ini with vim.
vim /etc/php.ini
cgi.fix_pathinfo=0
vim /etc/php-fpm.d/www.conf
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 2/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
PHP-FPM will run under the user and group 'nginx', change the value of the two lines below to 'nginx'.
user = nginx
group = nginx
Instead of using the server port, PHP-FPM will run under a socket file. Change the 'listen' value to the path '/run/php-fpm/php-fpm.sock' as
shown below.
listen = /run/php-fpm/php-fpm.sock
The socket file owner will be the 'nginx' user, and the permission mode is 660. Uncomment and change all values like this:
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
For the environment variables, uncomment these lines and set the values as shown below.
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Save the file and exit vim, then start PHP-FPM and enable it to run at boot time.
PHP-FPM is running under the socket file, check it with the command below.
The PHP and PHP-FPM 7.1 installation and configuration have been completed.
You can use MySQL or PostgreSQL for your Laravel project. I will use the MariaDB database server for this tutorial. It's available in the CentOS
repository. Install MariaDB-server with the yum command below.
When the installation is complete, start 'mariadb' and enable it to start at boot time.
MariaDB has been started and is running on port 3306, check it with the netstat command.
netstat -plntu
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 3/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Next, configure the root password for MariaDB with the 'mylsq_secure_installation' command below.
mysql_secure_installation
Type in your mariadb root password, remove the anonymous user etc.
PHP composer is a package manager for the PHP programming language. It has been created in 2011 and it's inspired by the Node.js 'npm' and
Ruby's 'bundler' installer. Install composer with the curl command.
When the installation completed, try to use the 'composer' command and you will see the results as below.
composer
In this step, we will create the nginx virtual host configuration for the Laravel project. We need to define the web root directory for this Laravel
installation, I will use the '/var/www/laravel' directory as web root directory.
mkdir -p /var/www/laravel
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 4/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Next, go to the nginx directory and create a new virtual host configuration file laravel.conf in the conf.d directory.
cd /etc/nginx
vim conf.d/laravel.conf
server {
listen 80;
listen [::]:80 ipv6only=on;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
Test the nginx configuration and make sure there is no error, then restart the nginx service.
nginx -t
systemctl restart nginx
The nginx virtual host configuration for Laravel has been completed.
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 5/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
cd /var/www/laravel
Laravel provides two ways for the installation of the framework on the server. We can install Laravel with the laravel installer, and we can install it
with PHP composer. In this tutorial, I will install Laravel by creating a new project with the composer command.
Wait for the Laravel installation to finish. This may take some time.
When the installation is complete, change the owner of the Laravel web root directory to the 'nginx' user, and change the permission of the
storage directory to 755 with the commands below.
In this tutorial, Laravel will run under SELinux 'Enforcing' mode. To check the SELinux status, run the command below.
sestatus
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 6/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Now we need to change the context of the Laravel directories and then apply the changes with the restorecon command. Run the SELinux
management commands as shown below.
Open your web browser and type in the Laravel URL of your server. We've defined the domain name for the Laravel in the Nginx virtual host file.
Mine is laravel.hakase-labs.co.
When you visit the domain name, you will see the Laravel home page.
Laravel installation with Nginx, PHP-FPM7, and MariaDB on CentOS 7 has been successful.
Reference
https://laravel.com/docs/5.4/installation
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 7/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Suggested articles
¿Préstamos sin pagar? Installing Nginx with Sistemas ERP Installing Laravel PHP
PHP 7 and MySQL 5.7 Framework on Ubuntu
(LEMP) on Ubuntu... 18.04 LTS for Apache
Ad resuelvetudeuda.com howtoforge.com Ad Epicor howtoforge.com
¿Crisis en México? How to Install Invoice How to Install Laravel 5 How To Monitor Your
Ninja on CentOS 7 PHP Framework with Linux Server With SMS
Nginx on Ubuntu 16.04... Alerts And...
Ad Agora Publicaciones howtoforge.com howtoforge.com howtoforge.com
7 Comment(s)
Add comment
Name * Email *
p
Submit comment
I'm not a robot
reCAPTCHA
Privacy - Terms
Comments
When I make vim conf.d/laravel.conf, I writed my servername (localhost.localdomain) but , when i testing, the page is always go to search page..
it this a naming problem??
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 8/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
I can't find anything under the folder /run/php-fpm/'. I don't have a file like 'php-fpm.sock'. Could you give me that file?
How do I go about setting up the Letsencrypt certificate, https connection in EC2 environment?
try your ip
I have followed all the steps but it gives me "403 Forbidden". Please any help
Thank you very much
Tutorials How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Sign up now!
Tutorial Info
40.2k Followers
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 9/10
23/5/2018 How to Install Laravel 5.x with Nginx and PHP-FPM 7.1 on CentOS 7
Popular Tutorials
https://www.howtoforge.com/tutorial/how-to-install-laravel-5x-with-nginx-and-php-fpm-7-on-centos-7/ 10/10