看到laravel是不是很给力,哈哈,是的,最近我们在研究学习laravel,确实是比较牛逼的框架,那么我们接下来就配置我们的vultr VPS上的PHP环境,并运行laravel程序。
PHP配置:文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
sudo vim /etc/php/7.1/fpm/php.ini 文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
将cgi.fix_pathinfo=1这一行去掉注释,将1改为0文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
FPM文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
sudo vim /etc/php/7.1/fpm/pool.d/www.conf文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
listen = /var/run/php7.1-fpm.sock文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
文章源自陈学虎-https://chenxuehu.com/article/2016/08/5507.html
Nginx配置
sudo vim /etc/nginx/sites-available/default
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel-ubuntu/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
创建网站目录, 并给权限:
mkdir /var/www
sudo chown -R www-data:www-data /var/www/
然后去git拉laravel的代码到/var/www目录下:
git clone xxx
然后我们去访问
http://45.63.66.142/
不好意思,出现错误了
遇到错误不要紧张,主要可能就是权限问题,我们依次去给权限就好了:
sudo chown -R www-data:www-data /var/www/xxx/
sudo chown -R 775 storage
sudo service nginx restart
service php7.1-fpm restart
如果不出意外,您应该就能看到漂亮的laravel欢迎页面了:
OK,这里就完成了部署,接下来要说一点好用的东西,就是我们每次GIT代码后,直接同步服务器更新,将在下面的教程中说明。
评论