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.
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.
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
If this comes out, the package called unzip is missing, so apt install unzip
If this comes out, the package called unzip is missing, so apt install php-mbstring
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.
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.
Or if you specify an IP address or port
php artisan --host=192.168.0.123 --port=9999
will do.
Recommended Posts