Home > Backend Development > PHP Tutorial > 一步一步部署Laravel项目

一步一步部署Laravel项目

WBOY
Release: 2016-06-23 13:14:02
Original
1285 people have browsed it

1. 安装nginx+php+mysql	```		sudo apt-get install nginx		sudo apt-get install mysql-server mysql-client		sudo apt-get install php5-fpm php5-cli php5-mcrypt 	```	>PHP配置	>1 `sudo vim /etc/php5/fpm/php.ini` 将配置文件中的cgi.fix_pathinfo=0前面的`;`,去掉	>2 启用php5-mcrypt: `sudo php5enmod mcrypt`	>3 重启php5-fpm: `sudo service php5-fpm restart`2. 创建网站根目录	`sudo mkdir /app`3. 配置nginx服务器	`sudo vim /etc/nginx/sites-available/default`	在配置文件中有`server`这个配置项,我们修改它:	```		server {	        listen 80 default_server;	        listen [::]:80 default_server ipv6only=on;	        root /app;		// 网站根目录	        index index.php index.html index.htm;	// 首页文件类型		        server_name ip_address; 	// 这里写公网ip地址		        location / {	                try_files $uri $uri/ /index.php?$query_string;	        }						# 这里要自己加上去,它是对php文件的处理			location ~ \.php$ {		        try_files $uri /index.php =404;		        fastcgi_split_path_info ^(.+\.php)(/.+)$;		        fastcgi_pass unix:/var/run/php5-fpm.sock;		        fastcgi_index index.php;		        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;		        include fastcgi_params;    		}			}	```4. 安装composer	- `sudo curl -sS https://getcomposer.org/installer | php`	- 将composer作为全局命令使用: `sudo mv composer.phar /usr/local/bin/composer` 	5. 进入我们的项目根目录	- `cd /app`	- git clone一个laravel或通过` composer create-project`这个命令创建一个新的laravel项目		> 注意: 如果是通过git clone的方式获取的laravel项目,需要在项目中创建一个.env文件,是一个配置文件,最后还要执行`sudo composer install`和`php artisan migrate` 来安装以来文件和数据库迁移		5. 文件夹权限问题	这个在laravel的官方文档就已经说明了,项目在部署时需要`bootstrap/`和`storage/`目录具有可读写权限。我们如下执行:	`sudo chown -R www-data:www-data /app`	`sudo chmod 775 /app/bootstrap`	`sudo chmod 777 /app/storage`---OK,至此,我们的Laravel项目的部署已经完成!
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template