Laravel
This is a first concept of this post, updates are pending
Table of contents
Introduction
I set up a new VPS, this time with Laravel as framework and composer. Instead of Apache, I thought let's try Nginx now.
Web Server
So, let's begin with a couple of commands to set up the LEMP stack on the VPS, I chose for a VPS based on Debian:
1passwd
2root
3adduser swimmer
4apt-get install nginx
5systemctl enable nginx.service
6
7apt-get install mariadb-server mariadb-client
8mysql_secure_installation
At this point a couple of questions need to be answered:
1Enter current password for root (enter for none): Just press the Enter
2Set root password? [Y/n]: Y
3New password: Enter password
4Re-enter new password: Repeat password
5Remove anonymous users? [Y/n]: Y
6Disallow root login remotely? [Y/n]: Y
7Remove test database and access to it? [Y/n]: Y
8Reload privilege tables now? [Y/n]: Y
Restart MariaDB server and install PHP:
1systemctl restart mariadb.service
2apt install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-mysql php-cli php-mcrypt php-zip
3
4nano /etc/php/7.0/fpm/php.ini
5
6# Edit file
7 memory_limit = 256M
8 upload_max_filesize = 64M
9 cgi.fix_pathinfo = 0
10# /Edit file
FTP Server
1apt install vsftpd ftp
2nano /etc/vsftpd.conf
3
4# Edit file
5 write_enable = YES
6# /Edit file
7
8systemctl restart vsftpd
Laravel Project
Install composer and create a Laravel project:
1curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
2
3cd /var/www
4composer create-project laravel/laravel swimmer --prefer-dist
Update the virtual host and restart Nginx:
1nano /etc/nginx/sites-available/laravel
2
3# Edit file
4 server {
5 listen 80;
6 listen [::]:80;
7 root /var/www/public;
8 index index.php index.html index.htm;
9 server_name laravel.swimmer.zone;
10
11 location / {
12 try_files $uri $uri/ /index.php?$query_string;
13 }
14
15 location ~ .php$ {
16 try_files $uri = 404;
17 fastcgi_split_path_info ^(.+.php)(/.+)$;
18 fastcgi_index index.php;
19 fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
20 include fastcgi_params;
21 fastcgi_param PATH_INFO $fastcgi_path_info;
22 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23 }
24 }
25# /Edit file
26
27ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/
28
29systemctl restart nginx.service