<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>laravel Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/laravel/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/laravel/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Thu, 27 Apr 2023 09:59:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://serverstadium.com/wp-content/uploads/2023/04/cropped-favicon-1-32x32.png</url>
	<title>laravel Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/laravel/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</title>
		<link>https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Thu, 07 Jan 2021 07:01:21 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=685</guid>

					<description><![CDATA[<p>This tutorial will help you setup Laravel with Nginx in Ubuntu. In this tutorial, we will use Ubuntu 18 server to deploy Laravel. Laravel is a web application framework written in PHP language. To setup Laravel in your Ubuntu Server with Nginx, we need to install the following requirements below: The web server The database PHP&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/">How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This tutorial will help you setup Laravel with <a href="https://serverstadium.com/knowledge-base/installing-lemp-stack-on-ubuntu-1804/">Nginx</a> in <a href="https://serverstadium.com/knowledge-base/installing-lamp-in-ubuntu/">Ubuntu</a>. In this tutorial, we will use Ubuntu 18 server to deploy Laravel. Laravel is a web application framework written in PHP language.</p>



<p class="wp-block-paragraph">To setup Laravel in your Ubuntu Server with Nginx, we need to install the following requirements below:</p>



<ul class="wp-block-list">
<li>The web server</li>
<li>The database</li>
<li>PHP 7.2</li>
<li>Composer</li>
<li>Laravel</li>
</ul>



<p class="wp-block-paragraph">In this case, we use Nginx as the web server software and Mariadb as the database software. Also, we only have to open the default port on ServerStadium Default Security Profile which is only open port 22, 80 and 443.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="803" height="387" class="wp-image-687" src="https://serverstadium.com/wp-content/uploads/2021/01/fw-img.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/fw-img.png 803w, https://serverstadium.com/wp-content/uploads/2021/01/fw-img-300x145.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/fw-img-768x370.png 768w" sizes="(max-width: 803px) 100vw, 803px" /></figure>



<p class="wp-block-paragraph">Without further ado, here are the steps to setup Laravel with Nginx in Ubuntu 18.04.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 1 – Install Nginx</h2>



<p class="wp-block-paragraph">Firstly, you can run “sudo apt-get update” to download package information from all configured sources.</p>



<p class="wp-block-paragraph">Then to install nginx you can run the following command below:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install nginx</p>
</blockquote>



<p class="wp-block-paragraph">After the installation process is complete, you can check nginx status by run:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl status nginx</p>
</blockquote>



<p class="wp-block-paragraph">And the output should be like this if nginx is active.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="994" height="257" class="wp-image-688" src="https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img.png 994w, https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img-300x78.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/nginx-status-img-768x199.png 768w" sizes="(max-width: 994px) 100vw, 994px" /></figure>



<p class="wp-block-paragraph">Or you can check it by opening your server IP public on your browser, and the page will display Apache2 Ubuntu Default Page as below.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1422" height="812" class="wp-image-690" src="https://serverstadium.com/wp-content/uploads/2021/01/pict03.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict03.png 1422w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-300x171.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-1024x585.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict03-768x439.png 768w" sizes="(max-width: 1422px) 100vw, 1422px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 2 – Install MariaDB</h2>



<p class="wp-block-paragraph">The second step is to install the database or MariaDB. To install it, you can use the following command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt install mariadb-server</p>
</blockquote>



<p class="wp-block-paragraph">Since we use the default source, At the time of writing, the version of MariaDB is 10.1.47. To check mariadb status, you can run this command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl status mariadb.service</p>
</blockquote>



<p class="wp-block-paragraph">The output will be like this if the service is running.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1033" height="336" class="wp-image-691" src="https://serverstadium.com/wp-content/uploads/2021/01/pict04.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict04.png 1033w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-300x98.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-1024x333.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict04-768x250.png 768w" sizes="(max-width: 1033px) 100vw, 1033px" /></figure>



<p class="wp-block-paragraph">With the following command above, the database is already installed, and you can login to the mysql without any password using root user. But if you want to setup the user for the mysql you can run the following command below and setup the password for root user.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>mysql_secure_installation</p>
</blockquote>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 3 – Install PHP 7.2</h2>



<p class="wp-block-paragraph">PHP 7.2 is included in the default Ubuntu repository for 18.04. We can list each of the available PHP 7.2 packages with the following command:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-cache pkgnames | grep php7.2</p>
</blockquote>



<p class="wp-block-paragraph">Next, we can install the packages that our application requires by typing:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install php curl git unzip</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php</p>
</blockquote>



<p class="wp-block-paragraph">Finally, we can restart nginx to allow PHP to run:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl restart nginx</p>
</blockquote>



<p class="wp-block-paragraph">Then, we can confirm the PHP version by type:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>php –version</p>
</blockquote>



<p class="wp-block-paragraph">Here is the output of the checking command version above.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="679" height="79" class="wp-image-692" src="https://serverstadium.com/wp-content/uploads/2021/01/pict05.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict05.png 679w, https://serverstadium.com/wp-content/uploads/2021/01/pict05-300x35.png 300w" sizes="(max-width: 679px) 100vw, 679px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 4 – Install composser</h2>



<p class="wp-block-paragraph">Since composer is already part of the repository, we can install it using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>apt-get install composer</p>
</blockquote>



<p class="wp-block-paragraph">To ensure that the composer is already installed, we can check it by running command “composer” and it will show the manual as below.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1091" height="835" class="wp-image-693" src="https://serverstadium.com/wp-content/uploads/2021/01/pict06.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict06.png 1091w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-300x230.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-1024x784.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/pict06-768x588.png 768w" sizes="(max-width: 1091px) 100vw, 1091px" /></figure>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Step 5 – Install Laravel using composer</h2>



<p class="wp-block-paragraph">When installing laravel or creating a laravel project, you must enter the directory where you want to save the project data, or you can create the project first and then move the data to the right locale where you want to save it.</p>



<p class="wp-block-paragraph">In this tutorial, I use /var/www/html as my data storage location, and my project name is testlaravel. Then to install laravel you can run this command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>composer create-project &#8211;prefer-dist laravel/laravel [projectName]</p>
</blockquote>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="607" height="586" class="wp-image-694" src="https://serverstadium.com/wp-content/uploads/2021/01/pict07.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict07.png 607w, https://serverstadium.com/wp-content/uploads/2021/01/pict07-300x290.png 300w" sizes="(max-width: 607px) 100vw, 607px" /></figure>



<p class="wp-block-paragraph">FYI, in the picture above, I give my project name &#8220;laraveltest&#8221; <br /><br />After laravel installation is complete, you can move the project folder to /var/www/html/ then change the owner of the project to www-data with the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>sudo mv [projectName] /var/www/html/</p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>chown -R www-data:www-data /var/www/html/[projectName]/</p>
</blockquote>



<p class="wp-block-paragraph">Now the next step is to config the virtual host so we can access the website through our browser. You can use the following command below to edit the virtual host file.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>nano /etc/nginx/sites-available/vhostlaravel.conf</p>
</blockquote>



<p class="wp-block-paragraph">After the text editor is opened, we can use the simple config below. <br /><br />NB: <br />&#8211; If you have a different project location change the root document location with your project location.</p>



<pre class="wp-block-code"><code>server {
     listen 80;
     listen [::]:80 ipv6only=on;

     # Log files for Debugging
     access_log /var/log/nginx/vhostlaravel-access.log;
     error_log /var/log/nginx/vhostlaravel-error.log;

     # Webroot Directory for Laravel project
     root /var/www/html/laraveltest/public;
     index index.php index.html index.htm;

     # Your Domain Name
     server_name www.your_domain.com your_domain.com;

     location / {
             try_files $uri $uri/ /index.php?$query_string;
     }

     # PHP-FPM Configuration Nginx
     location ~ \.php$ {
             try_files $uri =404;
             fastcgi_split_path_info ^(.+\.php)(/.+)$;
             fastcgi_pass unix:/run/php/php7.2-fpm.sock;
             fastcgi_index index.php;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include fastcgi_params;
     }
}</code></pre>



<p class="wp-block-paragraph">After we save the config, we need to create links file of the virtual host from /etc/nginx/sites-available to /etc/nginx/sites-enabled by using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>ln -s /etc/nginx/sites-available/vhostlaravel.conf /etc/nginx/sites-enabled/</p>
</blockquote>



<p class="wp-block-paragraph">Then we must test the virtual host config using the simple command &#8220;nginx -t&#8221;. Accordingly, if your virtual host config is correct, it will give an output like this:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="516" height="47" class="wp-image-695" src="https://serverstadium.com/wp-content/uploads/2021/01/pict09.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2021/01/pict09.png 516w, https://serverstadium.com/wp-content/uploads/2021/01/pict09-300x27.png 300w" sizes="(max-width: 516px) 100vw, 516px" /></figure>



<p class="wp-block-paragraph">After the output says that syntax is OK we can restart nginx to apply the virtual host using the following command below.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>systemctl restart nginx</p>
</blockquote>



<p class="wp-block-paragraph">To test our laravel project, we can change our local resolver file.<br />If you are on a Mac or Linux computer at home, you can edit the file needed by typing:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>nano /etc/hosts</p>
</blockquote>



<p class="wp-block-paragraph"><br />If you are using Windows desktop, you can edit file &#8220;hosts&#8221; from the notepad by accessing this folder:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>C:\Windows\System32\drivers\etc</p>
</blockquote>



<p class="wp-block-paragraph">Then assuming that your server’s public IP address is 97.22.10.9 , the lines we need to add to the &#8220;hosts&#8221; file would look something like this:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>97.22.10.9 www.your_domain.com your_domain.com</p>
</blockquote>



<p class="wp-block-paragraph">Finally, we can test to access our Laravel project through the browser, and the output will look like this.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" class="wp-image-697" src="https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1.png" alt="" width="580" height="310" srcset="https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1.png 1597w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-300x161.png 300w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-1024x548.png 1024w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-768x411.png 768w, https://serverstadium.com/wp-content/uploads/2021/01/laravel-home-page-1-1536x822.png 1536w" sizes="(max-width: 580px) 100vw, 580px" /></figure>



<p class="wp-block-paragraph">&nbsp;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/how-to-setup-your-own-laravel-with-nginx-in-ubuntu-18-04/">How to Setup Your Own Laravel with Nginx in Ubuntu 18.04</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
