Create project through composer
1.1 Run the command in the terminal to install laravelcomposer create-project --prefer-dist laravle/laravel slrApp
1.2 Configure the virtual domain name
1) Modify the hosts file in the terminal
1.1 sudo su
Obtain permissions
1.2 vim /etc/hosts
vim to modify the hosts file. After entering, go to the last line and press the i key to enter the editor.
1.3 127.0.0.1
slrApp.net
Enter what you want to use Domain name, press esc after modification to exit editing, then enter :wq to save
1.4 vim /private/etc/apache2/extra/httpd-vhosts.conf
vim edit httpd-vhosts.conf file
<VirtualHost *:80> DocumentRoot "/Users/zhouhongliang/Site/slrApp/public" ServerName slrApp.net ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common </VirtualHost>
Fill in the final path and domain name and change the path and domain name to your own
1.5 Restart apachesudo apachectl restart
1.6 An error is reported when accessing the domain name and the log file cannot be opened because permissions need to be added to the storage and bootstrap/cache in the project
1) In the terminal, enter the project root directory
2) After enteringsudo chmod -R 777 storage
3) Enter the bootstrap file again
4) Execute sudo chmod -R 777 cache/
and then access the Laravel project successfully.
For more Laravel related technical articles, please visit the Laravel Tutorial column to learn!
The above is the detailed content of Install Laravel on Mac computer. For more information, please follow other related articles on the PHP Chinese website!