Learn from me the installation of Laravel Laravel
- 2021-07-22 09:13:12
- OfStack
Installing Composer
The Laravel framework uses Composer (PHP package management tool, refer to Composer Chinese documentation) to manage code dependencies. First, you need to download the PHAR package file for Composer (composer. phar) and place it in the project directory or in the usr/local/bin directory for global calls across the system. In the Windows operating system, you can use the Windows installation tool of Composer.
Installing Laravel
Install through Laravel installer
Download the Laravel installer PHAR file first. For convenience, rename the file to laravel and move to the/usr/local/bin directory. Once done, simply type the simple laravel new command in the directory you specify to create a new Laravel installation. For example, laravel new blog will create a directory called blog that contains a new Laravel installation and the required dependencies. This installation method is much faster than installing through Composer.
Install Laravel with the Composer create-project command
You can also install Laravel by executing the Composer create-project command on the command line:
composer create-project laravel/laravel --prefer-dist
Install by downloading the Laravel package
After Composer is installed, download the latest version of the Laravel framework and unzip it to a directory on your server. Then run the command line command php composer. phar install (or composer install) in the root directory of the Laravel application to install all the framework dependencies. During this process, in order to complete the installation successfully, you need to install Git on the server.
When the Laravel framework is installed, you can update the framework using the command line command php composer. phar update.
Server environment requirements
The Laravel framework has one system requirement:
PHP Minimum version: 5.3. 7
MCrypt PHP Extension
Starting with version 5.5 of PHP, installation packages for some operating systems require you to manually install the JSON extension module of PHP yourself. If you are using Ubuntu, you can install it directly through the command apt-get install php5-json. Translator's Note: Ubuntu is still a fool!!!)
Configure
The Laravel framework is ready to use almost without configuration. You are free to start developing quickly. However, you may want to look at the app/config/app. php configuration file and related documentation first. It contains 1 configuration options that you may want to modify, such as time zone and region.
Once Laravel is installed, you should also configure your local environment. This will allow you to receive detailed error messages when developing on your local machine. By default, detailed error reporting is disabled in your production configuration file.
Note: You should never have app.debug set to true for a production application. Never, ever do it.
Permission setting
The Laravel framework has one directory that requires additional permissions: Write permissions need to be set for files in the app/storage directories.
Path setting
1 Some frame directory paths can be set. If you need to change the location of these directories, you can check the settings in the bootstrap/paths. php file.
Elegant link
Apache Server
The Laravel framework removes index. php from the link by setting the public/. htaccess file. If your server is using Apache, turn on the mod_rewrite module.
If the. htaccess file shipped with the framework doesn't work in your Apache environment, try the following version:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Nginx Server
If you are an Nginx server, you can make the URL more elegant by placing the following instructions in the URL's configuration file:
location / {
try_files $uri $uri/ /index.php?$query_string;
}