How to get started with laravel (Linux)

When I started using it, it didn't go well, so I'll summarize it so that people who are starting from now will not trip over it.

1. Install composer

composer is a tool for managing PHP libraries, and laravel uses it to install.


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');" 

If you execute the command on the second line and get "Installer corrupt", there is a possibility that the hash key (the part of the enumeration of numbers and Alfebet) is wrong, so <a href="https://getcomposer" Make sure it's not different from the Command-line installation on the .org/download/"> official site. If these are successful, you should have a composer.phar file.

./composer.phar --version

If the version information is displayed, the installation is complete. However, as it is, it can be executed only in the directory where composer.phar is located, so it is necessary to make it possible to execute it from anywhere.

#Find the location where PHP is installed
$ dirname $(which php)
/usr/bin/php

#Go to the same directory as PHP and give execute permission
$ mv ./composer.phar $(dirname $(which php))/composer && chmod +x "$_"

Now you can run it from anywhere with the command composer.

2. Install laravel

When you execute the command below, the application environment of laravel will be built with the directory called test under the current directory.

composer create-project laravel/laravel test

Solution for the error in composer create-project

unzip error

unzip.png If this comes out, the package called unzip is missing, so apt install unzip

mbstring error

mbstring.png If this comes out, the package called unzip is missing, so apt install php-mbstring

php-xml error

php-xml.png If this comes out, the package called unzip is missing, so apt install php-xml

If there are no errors, Applicaion key set successfully will be created and a laravel template will be created.

3. 3. Check if the app works

Let's actually access it using the simple server function and check if it is working.

php artisan serve

If you try to access "http://127.0.0.1:8000" and a screen like this appears, you are successful. laravel.png

Or if you specify an IP address or port

php artisan --host=192.168.0.123 --port=9999

will do.

Recommended Posts

How to get started with laravel (Linux)
How to get started with Scrapy
How to get started with Python
How to get started with Django
What I did to get started with Linux commands
Link to get started with python
Step notes to get started with django
How to get parent id with sqlalchemy
I tried to get started with Hy
How Python beginners get started with Python with Progete
Here's a brief summary of how to get started with Django
How to get all traffic through VPN with OpenVPN on Linux
Get started with MicroPython
Get started with Mezzanine
The easiest way to get started with Django
How to make Linux compatible with Japanese keyboard
Get started with Django! ~ Tutorial ⑤ ~
Get started with influxDB + Grafana
I tried to get started with blender python script_Part 01
How to get a logged-in user with Django's forms.py
Get started with Django! ~ Tutorial ④ ~
How to update with SQLAlchemy?
How to get more than 1000 data with SQLAlchemy + MySQLdb
How to cast with Theano
Get started with Django! ~ Tutorial ⑥ ~
How to Alter with SQLAlchemy?
Get started with Python! ~ ② Grammar ~
How to RDP with Fedora31
How to Delete with SQLAlchemy?
I want to get started with the Linux kernel, what is the list head structure?
How to get started with Visual Studio Online ~ The end of the environment construction era ~
Minimum knowledge to get started with the Python logging module
[Linux] [C / C ++] Summary of how to get pid, ppid, tid
[Linux] How to deal with garbled characters when viewing files
How to get into the python development environment with Vagrant
[Introduction to Python] How to get data with the listdir function
How to cancel RT with tweepy
Python: How to use async with
Get started with MicroPython (on macOS)
How to deal with imbalanced data
How to install python-pip with ubuntu20.04LTS
How to install wkhtmltopdf (Amazon Linux2)
How to deal with imbalanced data
How to install VMware-Tools on Linux
How to get the Python version
How to install MBDyn (Linux Ubuntu)
How to deal with DistributionNotFound errors
How to Data Augmentation with PyTorch
How to use FTP with Python
How to calculate date with python
How to install mysql-connector with pip3
How to check Linux OS version
How to INNER JOIN with SQLAlchemy
Get started with Python in Blender
How to install Anaconda with pyenv
How to authenticate with Django Part 2
How to authenticate with Django Part 3
Run the program without building a Python environment! !! (How to get started with Google Colaboratory)
[Cyberduck] How to exchange files on Linux (CentOS7) started by VirtualBox with mac using GUI
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
How to get the printer driver for Oki Mac into Linux