Install Laravel 5.1 on Ubuntu 16.04 Nginx
Introduction
Laravel is a free, open-source PHP web application framework that is highly popular with modern web developers. It leverages an expressive and elegant syntax to quickly develop robust web applications. In this tutorial, you’ll install Laravel 5.1 on an Ubuntu 16.04 server running Nginx.
Prerequisites
Before you begin with this guide, you should have a separate, non-root user account with sudo privileges set up on your server. To learn how to set up such a user account, follow our initial server setup guide for Ubuntu 16.04.
You’ll also need to make sure that you have Nginx installed and running on your system. If you haven’t installed Nginx yet, you can do so by following steps 1 and 2 of this guide, which explain how to add the Nginx repository to your system and install Nginx from it.
Install PHP and Related Modules
Laravel 5.1 requires PHP 5.5.9 or higher to run, so your first step will be to install it. To do this, type this apt-get command:
sudo apt-get update
sudo apt-get -y install php7.0-fpm php7.0-mbstring php7.0-xmlrpc php7.0-soap php7.0-gd php7.0-xml php7.0-cli php7.0-zip
This will install these required PHP modules:
- php7.0-fpm – Required for running PHP as an Nginx FastCGI process.
- php7.0-mbstring – Required for processing strings.
- php7.0-xmlrpc – Required for server communication over XML-RPC protocol.
- php7.0-soap – Required for server communication over SOAP protocol.
- php7.0-gd – Required for creating graphics with the GD library.
- php7.0-xml – Required for processing XML documents.
- php7.0-cli – Required for running the PHP command-line interface.
- php7.0-zip – Required for processing ZIP archives.
After all of these modules are installed, you can proceed.
Install and Configure Composer
Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies.
To install Composer on your server, type this curl command:
curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer
After the installation is complete, you can verify that the installed version is correct by typing:
composer –version
This will output something like this: Composer version 1.6.3 2018-01-31 16:28:17.
Install Laravel
Now that you have composer installed, you’re ready to install Laravel. First, create a directory where the Laravel files will live. To do this, enter the following commands:
sudo mkdir -p /var/www/laravel
sudo chown -R $USER:$USER /var/www/laravel
cd /var/www/laravel
Next, enter the command below to download Laravel 5.1:
composer create-project –prefer-dist laravel/laravel blog
This command will download all of the necessary files into a “blog” directory inside the “laravel” directory. To finish setting up your Laravel installation, enter the following commands:
cd blog
chmod -R 755 storage
chown -R www-data:www-data *
Create a Nginx Server Block for Laravel
Now that you have Laravel installed, it’s time to configure a server block to serve the files. To do this, create a file called laravel in the /etc/nginx/sites-available directory:
sudo nano /etc/nginx/sites-available/laravel
Paste these lines into the file:
server {
listen 80;
server_name 192.168.1.5;
root /var/www/laravel/blog/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
try_files $uri /index.php =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Once you have pasted the configuration into the file, save and close it. To enable the configuration, create a symbolic link from the file to the sites-enabled directory by typing this command:
sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/laravel
After creating the symbolic link, type this command to check for syntax errors in the Nginx configuration:
sudo nginx -t
If the command returns no errors, restart the Nginx service by typing:
sudo systemctl restart nginx
Conclusion
You should now have Laravel 5.1 installed and running on your Ubuntu 16.04 server. You can access your application by visiting your server’s IP address in your web browser.
FAQs
- Do I need Apache to run Laravel? – No, you can use Nginx as well. This guide shows how to install Laravel on an Ubuntu 16.04 server running Nginx.
- What PHP version do I need for Laravel 5.1? – Laravel 5.1 requires PHP 5.5.9 or higher.
Thank you for reading this article. For more information, please read our other articles on Laravel and Ubuntu.
Related Posts:
- How To Set Rails On Nginx Ubuntu 18.04 How To Set Rails On Nginx Ubuntu 18.04 Step 1: Install Ruby Using RVM The first step for setting up Ruby on Rails on an Ubuntu 18.04 server with Nginx…
- Install Laravel Nginx Ubuntu 18.04 Install Laravel Nginx on Ubuntu 18.04 Introduction In this tutorial, we will look at how to install Laravel with Nginx on an Ubuntu 18.04 server. Laravel is a powerful PHP…
- Install Squirellmail On Nginx Ubuntu Install Squirrelmail On Nginx Ubuntu 1. What is Squirrelmail? Squirrelmail is a webmail application written in PHP. It is often used as an email client for the Linux operating system…
- Nginx 1.4 6 Ubuntu Nginx 1.4 6 Ubuntu Overview of Nginx 1.4 6 Ubuntu Nginx is an open-source web server software used to serve webpages and HTTP requests. Nginx was initially developed for the…
- Wordpress Nginx Ubuntu 18.04 Wordpress Nginx Ubuntu 18.04 Overview WordPress is a popular web software used by millions of people around the world. It allows users to easily create and manage websites without the…
- Laravel Nginx Without Custom Domain Laravel Nginx Without Custom Domain Overview of Laravel Nginx Without Custom Domain Laravel is an open-source PHP web framework used to create powerful web applications. It is based on the…
- Lets Encrypt Nginx Ubuntu 14.04 With Nginx Conf Custom Let's Encrypt Nginx Ubuntu 14.04 with Nginx Conf Custom Introduction to Nginx Conf Custom Nginx Conf Custom is an open source solution for hosting web applications on Ubuntu 14.04. It…
- Laravel Nginx Not Custom Domain Laravel Nginx Not Custom Domain Overview of Laravel, Nginx, and Custom Domains Laravel is an open-source model-view-controller web application development framework written in PHP. It is the most popular framework…
- Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
- Nginx Command Not Found Ubuntu Nginx Command Not Found Ubuntu What is Nginx? Nginx (pronounced as Engine X) is an open source web server created to handle high traffic network applications, replacing traditional web servers…
- Laravel On Nginx Centos 7 Laravel On Nginx Centos 7 Introduction Laravel is an open-source MVC (model-view-controller) web framework for PHP. It is free and has been used by many developers to create great websites…
- Install Odoo 11 Nginx Ubuntu 16 Install Odoo 11 Nginx Ubuntu 16 What is Odoo 11 Nginx? Odoo 11 Nginx is an open source software package designed to facilitate secure and reliable web development. It is…
- Ubuntu 16 Bind9 Nginx Subdomain Ubuntu 16 Bind9 Nginx Subdomain Overview Ubuntu is a popular Linux-based operating system, often used in web hosting. Bind 9 is a DNS server, commonly used in Ubuntu, that helps…
- Reverse Proxy Nginx Ubuntu 18.04 Reverse Proxy Nginx Ubuntu 18.04 Introduction Reverse Proxy is a type of proxy server that forwards requests to another server. It is mainly used by web servers, such as Nginx,…
- The Serve Sha2 Nginx Code Igniter The Serve Sha2 Nginx Code Igniter What is Serve Sha2 Nginx Code Ignitor? Serve Sha2 Nginx Code Igniter is a completely open source web application development framework that enables developers…
- Tutorial Install Nginx Di Ubuntu Vps Tutorial Install Nginx Di Ubuntu Vps Step 1: Install Nginx The first step to install nginx in your Ubuntu VPS is to install the nginx package. To do this, use…
- How To Set Up Nginx Loadbalancer Ubuntu How To Set Up Nginx Loadbalancer Ubuntu Introduction to Nginx Loadbalancer Nginx Loadbalancer is a web application that lets you easily set up load balancing for your website. It is…
- Install Ssl Certificate Ubuntu 18.04 Nginx Install Ssl Certificate Ubuntu 18.04 Nginx Introduction To SSL And Why We Need It SSL (Secure Sockets Layer) is a security technology commonly used on the Internet to securely transmit…
- Stop Nginx Ubuntu 16.04 Stop Nginx Ubuntu 16.04 What is Nginx? Nginx is a web server and reverse proxy software. It is open source and widely used on the web. It is used to…
- Nginx Wordpress Ubuntu 18.04 Nginx Wordpress Ubuntu 18.04 Introduction to Nginx Nginx is a web server software for hosting websites and applications. It is open-source and highly configurable, making it a popular choice for…
- Deploy Laravel Nginx Ubuntu 17 Deploy Laravel Nginx Ubuntu 17 Requirements for Installing Laravel 5.4 on Ubuntu 17 This article will guide you through the process of installing Laravel 5.4 on Ubuntu 17. Before we…
- Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Introduction to PhpMyAdmin PhpMyAdmin is a web-based tool that enables the users to manage their MySQL databases. It also provides a graphical interface…
- Install Nginx 1.17 Centos 8 Install Nginx 1.17 Centos 8 Introduction to Nginx Nginx is one of the most popular web servers in the world. It is reliable, free, and open source software. It is…
- Virtualhost Nginx Ubuntu 16.04 Virtualhost Nginx Ubuntu 16.04 Introduction to Virtualhost Virtualhost is a software configuration option in web servers including Apache, Nginx, and more that allows a web server to host multiple web…
- Nginx Php Fpm 7.2 Laravel Nginx Php Fpm 7.2 Laravel Introduction to Nginx Nginx (pronounced “engine-x”) is a free, open-source web server software. It’s quickly becoming one of the most popular web servers, used by…
- How To Install Wordpress On Nginx How To Install Wordpress On Nginx Introduction If you’re looking to start your own website or blog, probably the easiest and most popular platform to choose is WordPress. WordPress is…
- Tutorial Start Nginx Ubuntu Webserver Tutorial Start Nginx Ubuntu Webserver Step 1: Prerequisites Before we start configuring Nginx as a web server on Ubuntu, we need to make sure we have the following prerequisites: A…
- How To Install Moodle On Nginx Postgresql Ubuntu How To Install Moodle On Nginx Postgresql Ubuntu Overview of Moodle and Requirements Moodle is an open-source learning management system (LMS) used by educators, businesses, and other organizations to create…
- Ubuntu 18.04 Nginx Hide Port Ubuntu 18.04 Nginx Hide Port Introduction to Nginx with Ubuntu Nginx is an open source web server and reverse proxy software that is commonly used in Linux servers. It is…
- Ubuntu Install Web Server Nginx Ubuntu Install Web Server Nginx Step 1: Install the Nginx Package The first step when installing Nginx on Ubuntu is to install the Nginx package from the Ubuntu repository. This…