php+mysql+nginx+laravel project deployment

Recently I found that my brain is not working well. I went back to the past. I still have to use a blog to record the bits and pieces. Not much nonsense. I like dry goods. I believe you are the same as me. I don’t like listening to people who are not using NB in ​​the end. Seomyeon started to dry goods directly


Before starting, I believe you should have installed the server, database, and PHP.


This is my environment

Okay, let’s start the project. Before we started, we used the PHP management tool composer. We have to say that this is a very good tool. The sad thing is that we need to overturn the wall, otherwise it will depend on your luck or use the domestic mirror installation

I am here to install it directly, it is useless. Domestic, I will introduce you to the domestic installation.

//下载安装脚本 - composer-setup.php - 到当前目录
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
//执行安装过程。
php composer-setup.php
//删除安装脚本
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer 
So you can use composer anywhere

1

This is the version of my composer 1.4.2

Start directly to use composer to create a project, this we named mylaravel, the project path is stored under val/www

Composer is used to create a project


After waiting for ten thousand years, it's finally finished. By the way, the next --prefer-dist is the most direct thing is that we don't need to know his source code, just package and download everything.

Then configure the mylaravel project


1. Modify service.php to index.php I have modified the command mv service.php index.php

2. Copy the .htaccess file in the public directory to the new directory of the mylaravel project. Command mv .htaccess ../


The advantage of this is that everyone knows that index.php is the entry file of the PHP program. If Baidu is written in the laravel framework, you will not visit www.baidu.com/index.php, but the www. that we often use. baidu.com is fine, the reason is the same

The next step is to configure the server

After that, it needs to be configured in nginx. There are various configurations on the Internet. If you believe it all, you will fall into the pit and cannot get up.

There are two ways to configure

1 Follow the official website

I didn’t give the domain name because I’m relatively poor, so I don’t have to give it if I installed a virtual machine. The port is the default port 80 of nginx. Below is the configuration according to the official statement. Just add root to localhost and return it. 

The last and most important step is to give the project file permission. There is a storage folder in the mylaravel project. If this folder does not give permission, the others will not be available to you. In fact, it is best to store/mylaravel/storage/framework/cache/ This file and the file permissions of /mylaravel/storage/framework/cache/logs, I have studied for a long time, but I didn’t give it to the last to get angry and gave the storage the maximum permission. Don’t follow me, I am after all On my local virtual machine, if it is on the real server, it is definitely not safe. Regarding the permission setting, you can directly chmod -R 777 /mylaravel/storage.

Seeing that this folder has changed color means that you have given the maximum read and write permissions (unreasonable!!!)

2. In the second way, the conventional configuration only needs to modify the things in localhost{ }, it does not need the official one

After all the configurations are complete, restart the nginx server. I compiled and installed it by myself. Start nginx /usr/local/nginx/sbin/nginx and it can be started, and then we can access the server. It should be because I don’t have a domain name. So visit the IP address directly, and the welcome page will appear

Does it appear? It’s as simple as that. This is the welcome page of laravel. As for how to deliver it, please pay attention to my blog. I will keep writing to create a complete laravel web project from scratch.

Well, the entire project is installed and deployed.

Guess you like

Origin blog.csdn.net/mzjmc123/article/details/75308958