Laravel 部署到阿里云 / 腾讯云

首先你需要一台阿里云/腾讯云服务器

安装系统选择 ubuntu 16.04

然后通过 ssh 登录远程服务器按下列步骤进行配置:

更新列表

apt-get update

安装语言包

sudo apt-get install -y language-pack-en-base

locale-gen en_US.UTF-8

安装常用软件

sudo apt-get install -y vim git zip unzip

安装PHP7

//请确保每一步没有出错,如果有报错,可尝试多安装几次

sudo apt-get install -y software-properties-common

sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

sudo apt-get update

apt-cache search php7.1

sudo apt-get install -y php7.1

sudo apt-get install -y php7.1-mysql

sudo apt-get install -y php7.1-fpm

sudo apt-get install -y php7.1-curl php7.1-xml php7.1-mcrypt php7.1-json php7.1-gd php7.1-mbstring

安装 Mysql

sudo apt-get install -y mysql-server

//安装完后需设置密码

安装 Nginx


//安装之前需确认是否安装了apache2,如果已经安装了apache2,需要先停止/卸载 apache2
//停止
sudo service apache2 stop
//卸载
sudo apt-get --purge remove apache2
sudo apt-get --purge remove apache2.2-common
sudo apt-get autoremove

//安装 nginx

sudo apt-get install -y nginx

配置 PHP7


sudo vim /etc/php/7.1/fpm/php.ini

//修改 cgi.fix_pathinfo=0 (注意去掉原有分号)

sudo vim /etc/php/7.1/fpm/pool.d/www.conf

//修改 listen = /var/run/php7.1-fpm.sock

配置 Nginx

sudo vim /etc/nginx/sites-available/default

//修改如下,根据自己的项目情况修改对应信息:'laravel-project'替换为你的项目,'server_domain_or_IP' 替换为你的网站域名或IP地址
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/laravel-project/public;

    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ /index.php?$query_string;      
    }

    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;
    }
}

拉取代码


//建议先将代码上传到云端代码仓库(github, coding)然后再在服务端上拉取

cd /var/www

git clone 地址

安装 Composer 并使用 Composer 安装代码依赖

访问 composer 官网 获取下面四行代码最新版,直接粘贴执行安装 Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

//然后移动 composer.phar
mv composer.phar /usr/local/bin/composer

//进入项目目录
cd /var/www/laravel-project

//执行 composer install
composer install

创建 .env 文件


cd /var/www/laravel-project

cp .env.example .env

vim .env

//根据项目实际情况修改 .env 文件

生成 laravel key

cd /var/www/laravel-project

php artisan key:generate

创建数据库,执行迁移


//首先登录 mysql 创建一个对应项目的数据库,名字应该和 .env 文件中的一致

cd /var/www/laravel-project

php artisan migrate

修改权限

sudo chown -R www-data:www-data /var/www

sudo chmod -R 777 /var/www/laravel-project/storage

重启 Nginx 和 PHP7 fpm

service nginx restart

service php7.1-fpm restart

搞定!

如果遇到问题请在下方留言,或者在此项目 下提 issue,我会及时回复

原文链接:Laravel 部署到阿里云/腾讯云

本作品采用《CC 协议》,转载必须注明作者和本文链接
长路漫漫,唯键盘作伴。:octocat: 我是猫哥,欢迎关注我的 「个人博客 」和微信公众号「前端猫哥」 :new_moon_with_face:
本帖由系统于 5年前 自动加精
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 117

楼主,部署过程中有个错误

sudo vim /etc/php/7.1/fpm/pool.d/www.conf

//修改 listen = /var/run/php7.1-fpm.sock

这里 listen 应该 是 /var/run/php/php7.1-fpm.sock 。在/var/run文件夹中没有php7.1-fpm.sock文件。该文件是在/var/run/php中。否则会报502 Gate 错误 而且重写文件中

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;
    }

fastcgi_pass unix:/var/run/php7.1-fpm.sock; 应该改为 fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

我刚刚按照以上步骤安装。直到遇到502 Gate 错误,然后查看nginx日志文件上面说/var/run/php7.1-fpm.sock文件不存在,于是做了那点修改,就成功了。

5年前 评论

有机会尝试一下。

5年前 评论

centos 7 上,好像没有php7的yum源,我编译安装,很费劲。

5年前 评论
爆炸青山绿水 4年前
前端猫哥

@xuanjiang1985 一直用ubuntu用的挺顺手的,就没用过centos了,23333,帮不上忙了,如果服务器上没啥东西的话可以重装个ubuntu嘛,按照我这个保证可以成功,我已经部署过很多次

5年前 评论
颜⑧

@xuanjiang1985 cento redhat 系统可以使用 https://www.softwarecollections.org/en/ ,scl源是系统官方推荐的。

5年前 评论

502 Bad Gateway
nginx/1.10.3 (Ubuntu)
配置完之后就是这样

5年前 评论
前端猫哥

@Mtimes

sudo service php7.1-fpm restart

这个运行了吗

5年前 评论

@SadCreeper 运行了。fastcgi_pass在哪里改。说php的路径不对好像。

5年前 评论
前端猫哥

@Mtimes
PHP装好后只需要设置这两个地方:在vim编辑器中先用 /cgi.fix_pathinfo= 搜索到 cgi.fix_pathinfo=1然后改成0,第二个同理,是修改不是添加啊,其他的不用改

sudo vim /etc/php/7.1/fpm/php.ini

//修改 cgi.fix_pathinfo=0

sudo vim /etc/php/7.1/fpm/pool.d/www.conf

//修改 listen = /var/run/php7.1-fpm.sock
5年前 评论

都加了呀

2018/03/28 17:40:08 [crit] 3143#3143: *5 connect() to unix:/var/run/php7.1-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 58.213.64.133, server: www.nous.vip, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.1-fpm.sock:", host: "www.nous.vip"

日志是这样的

5年前 评论

@SadCreeper 我找到错误啦。谢谢。多打了个字母

5年前 评论
前端猫哥

@Mtimes 应该就是你没有配置下面一项,导致的

sudo vim /etc/php/7.1/fpm/pool.d/www.conf

//修改 listen = /var/run/php7.1-fpm.sock

我刚才在我的服务器上进去吧这句话改了一下,然后重启 php7.1-fpm 也变成了 502 Bad Gateway,改回来重启就好了,你再试试? 改完php配置要重启才生效

5年前 评论
前端猫哥

@Mtimes 好吧= = OK

5年前 评论

在阿里云上把《Laravel 教程 - Web 开发实战入门 ( Laravel 5.5 )》的例子给部署上去了,虽然折腾的很晚,但还是成功了。您的教程没有问题,每一步都很顺利。但是因为第一次使用阿里云的ecs,有三个地方还是花费了一些时间。
1.更换ecs的操作系统,CentOs换到Ubuntu,使用阿里云提供的公用镜像可以很方便的切换过来。
2.http访问不了。阿里云的ecs的安全组设置,需要添加入站规则,开放80端口。
3.程序中要发送邮件。阿里云ecs封禁了25端口。使用qq邮箱的587端口,smtp也能发信成功。

以上

5年前 评论
ThinkQ

qq邮件发送,本地可以,发布到线上不行,后来知道25端口禁了。587可以发送。很OK。

5年前 评论
前端猫哥

@colbertwong 现在连80都要开了吗:joy: ,记得以前是默认开80,阿里云的发送邮件采用过,可以用80端口发,但是发到qq邮箱会进垃圾箱,所以还是用QQ把:joy:

5年前 评论
前端猫哥

@ThinkCsly 阿里云也禁了25,这里边一定有故事

5年前 评论

感谢!按照以上步骤部署成功啦

5年前 评论
peterxu

感谢楼主,找了很多教程都部署不成功;按照这个教程设置了没有问题,已经上线了。

删除apache2及相关组件的时候可以参照以下代码:

$ sudo apt-get --purge remove apache2
$ sudo apt-get --purge remove apache2.2-common
$ sudo apt-get autoremove
5年前 评论
前端猫哥

@peterxu 可以,感谢提供了部分代码,我就加上去了2333

5年前 评论

安利一个自动配置环境的脚本 https://oneinstack.com/

5年前 评论
前端猫哥

@JackFu 看起来还不错,下次试试,不过部署laravel应该还要手动一下

5年前 评论

请问按照这个步骤安装PHP7.1 能运行laravel5.6版本吗,

5年前 评论
前端猫哥

@wanzhiqiang 没试过5.6,应该可以

5年前 评论

很简单的部署,希望能够出个CI

5年前 评论

感谢,一次部署成功~顺便问一下大神请问如果我github上更新了代码,如何同步到我的云服务器上呢?

5年前 评论
前端猫哥

@qq3943 在服务器上 git pull 就行了,如果更新了依赖或者改动了数据库,服务器上也需要对应改动

5年前 评论

感谢,按照楼主的部署成功了,可是为什么访问这么慢呢?所有页面,打开都得10S以上,百度折腾了好久,也没解决。

5年前 评论
前端猫哥

@Anlior 你用了 vue 或者 react 吗,是不是没运行 npm run production

5年前 评论

@SadCreeper 没有用vue 和 react ,也没有运行 npm run production。 我发现需要访问数据库的就很慢,不拿数据的静态页面就很快了。那我现在应该怎么做?我没有用 vue 和 react 也要运行 npm run production吗?

5年前 评论
前端猫哥

@Anlior 如果你没用vue 和 react 这些就不用运行 npm run production,进network看下是哪个步骤最耗时间,是不是你用的图片太大了

5年前 评论

然而腾讯云上apt-get并不能安装php7.1,气死我了

5年前 评论

@SadCreeper 我的页面没有图片,最耗时间的是路由,很奇怪。截图了

file

5年前 评论
前端猫哥

@sweet 直接装不得行,要通过 ppa,你看我给的代码里有

5年前 评论
前端猫哥

@Anlior 一个请求12s,而且底下的请求都是0,是有点奇怪,在本地没事,放到服务器上就这样了吗?

5年前 评论

@SadCreeper 是啊,所有的时间都花在TTFB上了,应该是跟数据库有关,有没有好的方法或工具推荐,我找找具体原因。

file

5年前 评论
前端猫哥

@Anlior 没遇到过这种情况 :joy: 主要是都没报错,如果是请求 timeout 按理说也会报个错

5年前 评论

@SadCreeper :joy: :joy: :joy:我再找找原因,谢谢你。

5年前 评论
gobro

@SadCreeper 大佬,已有LARAVEL 项目,如何迁移呢?从A 云服务器 迁移到 阿里云的 ECS?

5年前 评论

楼主,部署过程中有个错误

sudo vim /etc/php/7.1/fpm/pool.d/www.conf

//修改 listen = /var/run/php7.1-fpm.sock

这里 listen 应该 是 /var/run/php/php7.1-fpm.sock 。在/var/run文件夹中没有php7.1-fpm.sock文件。该文件是在/var/run/php中。否则会报502 Gate 错误 而且重写文件中

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;
    }

fastcgi_pass unix:/var/run/php7.1-fpm.sock; 应该改为 fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;

我刚刚按照以上步骤安装。直到遇到502 Gate 错误,然后查看nginx日志文件上面说/var/run/php7.1-fpm.sock文件不存在,于是做了那点修改,就成功了。

5年前 评论
前端猫哥

@gobro 你已有项目没在云上吗,如果没在云上建议先推到云端,再从另一台服务器git clone

5年前 评论
前端猫哥

@Slairmy 网上查了下,这个文件好像是自动生成的,不管填哪个路径应该都可以,502的话一般重启下php-fpm 就好了,猜测是在重启的时候会自动生成php-fpm.sock 文件

5年前 评论
前端猫哥

@cocoyo 这个用过,失败了,然后就没然后了。。

5年前 评论

个人觉得为何不使用一些方便的开源的一件安装包呢?
oneinstack 。这种自己来一步步搞的花费时间效率也不高(个人感觉) :)
当然如何是想了解如何搭建lnmp环境的 这种也是一种学习。

5年前 评论
前端猫哥

@iMactool 一键安装不出问题的话是很方便,出了问题就尴尬了,其实手动配置熟了的话也就几十分钟的事,而且可以边配边做别的,还好

5年前 评论

@SadCreeper :) ,恩,这种环境部署一般都是个人爱好吧~

5年前 评论
前端猫哥

@iMactool 哈哈算是吧

5年前 评论

大佬,我用的是laravel5.4,请问我把项目上传到github的话是否需要把vendor/目录也上传上去呢,

我上传了这个目录(没遵循.gitignore的默认配置),我在执行composer install的时候会出现:

In Connection.php line 647:

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from `admin_permissions`)

In Connector.php line 68:

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)

Script php artisan optimize handling the post-install-cmd event returned with error code 1

我要不要放弃vendor/目录再重新部署一次呢,求指点~~~

5年前 评论
前端猫哥

@moonCat 你这个报错是mysql没连上,检查下.env中的mysql账号密码和服务器上设置的是否一致

5年前 评论
ThinkQ

很好啊

5年前 评论

@SadCreeper 谢谢大佬!我还想问个问题,我在执行php artisan的时候会出现以下错误提示:

In Connection.php line 647:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel54.admin_permissions' doesn't exist (SQL: select * from `admin_permissions`)

In Connection.php line 319:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel54.admin_permissions' doesn't exist

我最近刚接触laravel,想问一下为什么我想执行php artisan migrate之前会提示我数据库表不存在,我还没有迁移呀,这样不就陷入了死循环,请问我是不是在这之前的哪里没有做导致了这样子,还是依旧因为我.env文件配置有错呢

5年前 评论
前端猫哥

@moonCat 迁移里不仅可以创建表,还可以查询表,插入数据等,看下你的迁移文件里是不是在创建表之前就执行了查询

5年前 评论

@SadCreeper 我创建的所有迁移文件都没有的呢,看起来只要我执行artisan命令就一定会查询,就在刚才我直接把我本地的数据库上传到了服务器,现在就不报错了,每次看到那个提示都好绝望。。。
谢谢大佬,我先看看能不能继续把项目跑起来!

5年前 评论

@SadCreeper 我成功了!谢谢大佬的分享和帮助!

5年前 评论
前端猫哥

@moonCat :+1: :smirk:加油

5年前 评论
ThinkQ

这样部署的话 怎么如果要添加PHP扩展怎么添加呢?

5年前 评论
前端猫哥

@ThinkCsly 直接登录云服务器安装即可

5年前 评论
ThinkQ

你好,你如安装Phalcon7扩展。
下面是文档:http://www.myleftstudio.com/reference/inst...

file;

git clone --depth=1 git://github.com/dreamsxin/cphalcon7.git
cd cphalcon7/ext
phpize
./configure
make && sudo make install
编译时候:phpize在哪里啊?

5年前 评论
前端猫哥

@ThinkCsly 这个和laravel 没关系吧,ubuntu 的使用,搜一下应该教程很多的

5年前 评论
zhanghaidi

有没有php7编译安装的方法,最好是有安装redis,memcached,和libzip等比较全面的扩展方法?

5年前 评论
你看我吊吗啊

mysql装上了还没配置,执行 composer install的时候警告,

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/php_mbstring.dll' - /usr/lib/php/20160303/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/php_openssl.dll' - /usr/lib/php/20160303/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework v5.5.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.40 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.39 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.38 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.37 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.36 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.35 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.34 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.33 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.32 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.31 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.30 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.29 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.27 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.26 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.25 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.24 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.23 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.22 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.21 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.20 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.19 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.18 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.17 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.16 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.14 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.13 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.12 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.11 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.10 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v5.5.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for laravel/framework 5.5.* -> satisfiable by laravel/framework[v5.5.0, v5.5.1, v5.5.10, v5.5.11, v5.5.12, v5.5.13, v5.5.14, v5.5.15, v5.5.16, v5.5.17, v5.5.18, v5.5.19, v5.5.2, v5.5.20, v5.5.21, v5.5.22, v5.5.23, v5.5.24, v5.5.25, v5.5.26, v5.5.27, v5.5.28, v5.5.29, v5.5.3, v5.5.30, v5.5.31, v5.5.32, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.38, v5.5.39, v5.5.4, v5.5.40, v5.5.5, v5.5.6, v5.5.7, v5.5.8, v5.5.9].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.1/cli/php.ini
    - /etc/php/7.1/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.1/cli/conf.d/10-opcache.ini
    - /etc/php/7.1/cli/conf.d/10-pdo.ini
    - /etc/php/7.1/cli/conf.d/15-xml.ini
    - /etc/php/7.1/cli/conf.d/20-calendar.ini
    - /etc/php/7.1/cli/conf.d/20-ctype.ini
    - /etc/php/7.1/cli/conf.d/20-dom.ini
    - /etc/php/7.1/cli/conf.d/20-exif.ini
    - /etc/php/7.1/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.1/cli/conf.d/20-ftp.ini
    - /etc/php/7.1/cli/conf.d/20-gettext.ini
    - /etc/php/7.1/cli/conf.d/20-iconv.ini
    - /etc/php/7.1/cli/conf.d/20-json.ini
    - /etc/php/7.1/cli/conf.d/20-mysqli.ini
    - /etc/php/7.1/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.1/cli/conf.d/20-phar.ini
    - /etc/php/7.1/cli/conf.d/20-posix.ini
    - /etc/php/7.1/cli/conf.d/20-readline.ini
    - /etc/php/7.1/cli/conf.d/20-shmop.ini
    - /etc/php/7.1/cli/conf.d/20-simplexml.ini
    - /etc/php/7.1/cli/conf.d/20-sockets.ini
    - /etc/php/7.1/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.1/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.1/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.1/cli/conf.d/20-tokenizer.ini
    - /etc/php/7.1/cli/conf.d/20-wddx.ini
    - /etc/php/7.1/cli/conf.d/20-xmlreader.ini
    - /etc/php/7.1/cli/conf.d/20-xmlwriter.ini
    - /etc/php/7.1/cli/conf.d/20-xsl.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
ubuntu@VM-0-15-ubuntu:~/code/bbs$ 

我开始方了 。。百度半天没搞定

5年前 评论
你看我吊吗啊

我检查了一下『安装PHP7』这一步,里面最后一行的命令,有执行不成功的,比如sudo apt-get install -y php7.1-curl,他就提示Depends: libcurl3 (>= 7.44.0) but 7.35.0-1ubuntu2.16 is to be installed 安装他所需的依赖版本过低,可是我去更新这个依赖libcurl3 又更新不了,。

5年前 评论
前端猫哥

@JeffLi 安装PHP里每一步要确保成功,有时候是会失败,多安装几次试试,如果是一个刚初始化过的阿里云/腾讯云,应该没啥问题,如果还是有问题,只能单独解决了

5年前 评论
你看我吊吗啊

@SadCreeper 收到 我再重新安装一下

5年前 评论

请问怎么安装GD库?

5年前 评论

sudo apt-get install -y mysql-server 这步设置密码后一个多小时了一片空白这是个什么情况?继续等还是

5年前 评论

@peterxu sudo apt-get install -y mysql-server 安装mysql设置密码后一个多小时了一直没反应窗口闪烁,你安装的时候有遇到吗?

5年前 评论

请问在 腾讯云的Ubuntu上面 .env里面的配置怎么写?数据库migrate出错:
```SQLSTATE[HY000] [1045] Access denied for user 'VM-0-12-ubuntu'@'localhost' (using password: YES) (SQL:
select * from information_schema.tables where table_schema = sample and table_name = migrations)

5年前 评论

问题解决了,成功部署在腾讯云上面。

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sample
DB_USERNAME=root
DB_PASSWORD='123456' 

那个密码一定记得加引号!!!!被这个坑惨了

5年前 评论
前端猫哥

@Jimi2333 是你设定密码的时候就加了引号吧??我都没加过引号

5年前 评论

修改权限,出现问题

root@iZwz9b3gsasfxee9mgvdt8Z:~# sudo chown -R www-data:www-data /var/www

sudo: unable to resolve host iZwz9b3gsasfxee9mgvdt8Z

5年前 评论

一遍过! 没有遇到任何错误! 这教程太棒了,很有用,感谢!

5年前 评论
前端猫哥

@嘉兴程序员huangQinYe 你这个图文有联系吗= =,报错的话猜测是 laravelAdmin 中某个地方请求了外部链接,然后外部链接失效了?图的话,这篇文章底下评论中有解决方案 问答:Storage 使用中的一个问题

5年前 评论
前端猫哥

@python66 这个没遇到过,百度了下貌似改 hosts 文件可以解决,试试

5年前 评论
前端猫哥

@stefan 哈哈,恭喜恭喜 :smirk:

5年前 评论

@SadCreeper 按照你这教程安装之后的环境应该是没有phpize的吧? 因为我要在当前环境下安装memcache缓存服务器,之前尝试安装 好像是要通过phpize进行编译安装,然后发现没有phpize 于是去百度安装phpize 但尝试几次 都没有安装成功; 网上一般是说 sudo apt-get install php5-dev 用这个命令安装 当然我也试过安装 php7-dev 但好像都是安装不了phpize 不知道你有没有这方面的了解,望指点,谢谢!

5年前 评论

@SadCreeper 具体报错信息我忘了,好几天前尝试的了; 如果需要,我下午再去试试安装,把报错信息也给你看看?

5年前 评论
前端猫哥

@stefan 没用过 :joy: 加油,整好了发篇博客 :smirk:

5年前 评论
Code_Er

安装php7.1 curl中报了一个依赖包的问题,楼主可以指教一下吗?

file

5年前 评论
前端猫哥

@Code_Er 你是ubuntu14.04 以上吗?

5年前 评论
Code_Er

@SadCreeper 是的ubuntu16.0.2 问题解决了 原因是网易镜像有问题

5年前 评论
前端猫哥

@Code_Er 网易也出云了?=,=

5年前 评论
Code_Er

@SadCreeper 不是 是那个apt-get那个镜像出问题了 导致了安装那些拓展不行 我之前就是用网易的镜像后面换成清华的才解决了

5年前 评论

严格按照教程执行命令的难道没有碰到 root 用户不让执行 composer 的问题吗?

aliyun的服务器默认连上去就是 root 啊。

5年前 评论
前端猫哥

@zhangpipi 我记得 root 是警告吧,应该还是可以执行的

5年前 评论

@SadCreeper
我是想执行一下
composer config -g repo.packagist composer https://packagist.laravel-china.org
提示 [root] 不给执行。 我就放弃了,去新增了用户。没有去尝试 composer install了。
有可能新版的完全禁了吧,也有可能可以。。。 :grin:

5年前 评论

一步步来的最后显示403forbidden怎么办啊

5年前 评论
前端猫哥

@DEKU233 解决了没有?没有的话看看是不是这个问题:问答:自己配置 lnmp 运行 Laravel 出现了 403 Forbidden?

5年前 评论

@zhangpipi 也可以忽略。是一个警告错误。速度比较慢,等一等就可以了。也可以配置 composer 的镜像加速。
composer create-project --prefer-dist laravel/laravel

5年前 评论

@SadCreeper 请教你两个问题

  • 部署laravel项目选用centos,还是ubutu?另一方面,从长远角度来说,那个支持的软件更好更稳定,可以作为学习陪伴
  • 我部署到阿里云的centos系统,首页可以访问,其他的都报404错误,这个怎么办?

    现在正在摸索期间,以后想在laravel的道路上发展,请教下
5年前 评论
前端猫哥

@满矅帆

  1. 我没用过centos,我一直用的ubuntu,目前还没遇到过不能解决的问题
  2. 应该是路径问题,服务器的根目录要设置到代码的 public 文件夹下
5年前 评论

@SadCreeper
1.这个问题已经解决,是网站的伪静态设置造成的,谢谢你:smile:
2.想请教下你这边为什么选择的是ubutu?我听说服务器层centos居多,但是我看laravel项目开发ubutu用的人比较多而且资源丰富

5年前 评论
前端猫哥

@满矅帆 为啥用ubuntu大概就是觉得Homestead是 ubuntu,服务器也用ubuntu可能部署起来方便,后来就用习惯了= =

5年前 评论

请教一个楼主,如何再/etc/nginx/sites-available/default 里放两个项目?可以放两个吗?

5年前 评论
前端猫哥

@嘉兴程序员huangQinYe
http://dmmylove.cn/articles/13

5年前 评论

Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

5年前 评论

@Mtimes 请问下你的 nginx错误日志 是在哪里看的 我是报500错误

4年前 评论
前端猫哥

@Tibbers 500错误是laravel 错误吧,看 storage/logs/laravel.log 里面的内容

4年前 评论

2019-06-15 21:17:54] local.ERROR: No hint path defined for [sudosu]. (View: /var/www/FineReportChina/resources/views/layouts/app.blade.php) (View: /var/www/FineReportChina/resources/views/layouts/app.blade.php) {"exception":"[object] (ErrorException(code: 0): No hint path defined for [sudosu]. (View: /var/www/FineReportChina/resources/views/layouts/app.blade.php)

错误:没有为[sudosu]定义提示路径。

提示是没有 提供路径 这种是什么原因呢

4年前 评论

非常感谢,我一直以为500是服务器端报错,一直在找 nginx的配置和错误日志,结果最后发现是 代码的问题 .

就是那个 sudosu模板报错的问题. 你的教程 是非常实用的 谢谢

4年前 评论
前端猫哥

@Tibbers :smirk:

4年前 评论

大佬, 请教一个 前端的问题, laravel Mix ,的样式没出来 . 在生产环境应该执行什么样的代码呢.

// 运行所有 Mix 任务...
npm run dev

// 运行所有 Mix 任务并缩小输出..
npm run production 监控修改并自动编译

npm run watch

// 在某些环境中,当文件更改时,Webpack 不会更新。如果系统出现这种情况,请考虑使用 watch-poll 命令:

npm run watch-poll.

那些样式的路径是 http://localhost/ext/prism/prism.css

是localhost路径 ,不是实际的项目路径

4年前 评论
前端猫哥

npm run production,不生效的话清下浏览器缓存试试

4年前 评论

[BABEL] Note: The code generator has deoptimised the styling of /var/www/test/resources/assets/js/SemanticUI/semantic.js

翻译:+1:
注意:代码生成器对/var/www/test/resources/assets/js/SemanticUI/semantic.js的样式进行了去(取消)优化
因为它超过了500KB的最大值。

as it exceeds the max of 500KB.
我重新执行 npm的 时候 发现 又这么一句报错,

因为js>500kb 所以取消了对 xxx.js的优化.

请问这个是属于 webpack的问题吗

4年前 评论
前端猫哥

@Tibbers 这个问题没遇到过,但是我的js文件都有几MB,并没有报这个错,我随便百度了一下,有些解决方案,你看看吧,应该不是啥大问题

4年前 评论

刚刚接触laravel和GitHub,谢谢您终于让我知道了自己写的项目上传到GitHub然后怎么和服务器里更新代码。然后现在就还有一个疑惑,就是按照本站的laravel课程中修改了/vendor/laravel/里的某些代码,默认github没更新上去,那我应该如何让我的服务器里的同步这些代码哈?

4年前 评论

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.1
E: Couldn't find any package by regex 'php7.1' 这是怎么回事呀

4年前 评论

请问 我运行artisan命令 都会这种报错,事什么原因,卡在这好久了 PHP Warning: require(/var/www/weibo/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/weibo/artisan on line 18 PHP Fatal error: require(): Failed opening required '/var/www/weibo/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/weibo/artisan on line 18

4年前 评论

厉害,按着你的方法配置了php7.3版本 捎带一提 sudo apt-get install -y php7.1-mcrypt,php版本大于7.1不需要安装这个包,7.2以上已经弃用mcrypt加密,使用sodium替代,默认在php.ini中已经启用。

3年前 评论
前端猫哥

哈哈,这边文章很久没更新了,原文里我也更新到7.3了,最近还一直在用这套配置流程,一直很顺滑

3年前 评论

@Slairmy 是的,我也遇到类似的问题了,按照你的方法解决了

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!