部署自己的代码到服务器
打赏作者

adamwang

Good!

27631022

☁ warn [master] ⚡ git push -u origin master
提示下面这行错误,貌似443端口不通怎么解决哈,换了几个墙址了, Failed to connect to github.com port 443: Operation timed out

DPPCoder

root@10-23-202-21:/var/www# git clone git@github.com:DPPCoder/HTMl-TEST.git HTML
Cloning into ‘HTML’…
Warning: Permanently added the RSA host key for IP address ‘192.30.255.112’ to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

JellyBool 回复 DPPCoder

使用这个地址 clone :

https://github.com/DPPCoder/HTMl-TEST.git
143kk 回复 DPPCoder

需要在github上添加公钥

DanceSmile

什么时候讲一下docker

JellyBool 回复 DanceSmile

这个没有什么排期,我不会 docker

kangzhongyao 回复 JellyBool

is keyp 是什么鬼,键盘最左上方是esc啊

JellyBool 回复 kangzhongyao

esc 就是 escape 的简写吧

mouyong 回复 JellyBool

大佬不打算研究下嘛?docker 挺好的。我想了解 docker 集群相关的。前几天看到 Github 切换到 docker 集群 k8s(kubernetes) 上,体验好棒的感觉

JellyBool 回复 mouyong

啊哈,这个我目前还没有精力去研究。

ZhuChunYang2019 回复 JellyBool

大佬好实诚哈,哈哈哈啊

chenxin

你这个望远镜似的的东西是什么?

JellyBool 回复 chenxin

这是一个小应用 mousepose

biggerdong

想知道服务器clone完github的代码后,如果本地想修改push了github的代码后,服务器能通过什么命令把最新的代码给拉下来?(不使用webhook)

JellyBool 回复 biggerdong

在服务器上,进入到网站的根目录,类似 /var/www/phpjit 执行 git pull

呵二师兄

你这个是什么字体?

jeffierw

想问一下用git连接服务器的时候(ssh ubuntu@119.28.136.90
)提示 Permission denied (publickey). 咋办。。

JellyBool 回复 jeffierw

你在服务器端粘贴 authorized_keys 的时候是用的什么用户身份。记得要 ubuntu 的身份

jeffierw 回复 JellyBool

是要把主机提供的SSH密钥粘进去啊?不太懂命令行操作。。 请问怎么知道自己用的什么身份啊。。我本地cat打开ssh文件复制 然后vim authorized_keys 就本地站上去了还是不行。。

JellyBool 回复 jeffierw

主机一开始登录的时候,不是 ubuntu 的用户身份么?命令行就有提示的啊类似ubuntu@10-29-82-1 这种。话说你用的是 ucloud 么

jeffierw 回复 JellyBool

不是 是 腾讯云的学生机。。 不啊 我打开git bash 是本地用户user啥的 我登都登不上。。难道说要用linux环境? 我是w10。。

JellyBool 回复 jeffierw

额。。。腾讯云我记得默认就是 root 用户吧。你应该这样登录:ssh root@你的ip

big tree

我很不幸的又出了个403的错误 403 Forbidden nginx/1.10.3 (Ubuntu) 执行service nginx restart后发生的 然后我把laravel项目删掉后就会变成404 Not Found

JellyBool 回复 big tree

权限没给对呗,你的 web root 是需要 www-data 这个用户所有的

big tree 回复 JellyBool

要怎么给?能写下执行命令吗?

JellyBool 回复 big tree

sudo chown -R 。。。一般就是这个

big tree 回复 JellyBool

sudo chown -R :www-data /var/www/laravel
sudo chmod -R 775 /var/www/laravel/storage?
这个我给过

JellyBool 回复 big tree

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

big tree 回复 JellyBool

也没用,我没git laravel项目的时候执行service nginx restart还是nginx的欢迎页面,一旦拉取到项目再重启nginx就会403

JellyBool 回复 big tree

拉取代码下来,修改 nginx 的配置,root 和 index 这些就好

big tree 回复 JellyBool

还是不行,我把root 修改回root /var/www/html 就会变回nginx欢迎页面 修改为root /var/www/laravel 就会403 这说明laravel这个项目没有权限?但我把3个要给的权限都来回试了n次了

JellyBool 回复 big tree

root /var/www/laravel/public

这样试试,

big tree 回复 JellyBool

这样做会在403的基础上自动下载一个文件

JellyBool 回复 big tree

重写规则没写对,php 的 location 没对吧

big tree 回复 JellyBool

/etc/nginx/sites-available/default
location ~ .php${
try_files uri/index.php=404;fastcgisplitpathinfo(.+\.php)(/.+)uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+);
fastcgi_pass unix:/var/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME documentrootdocument_rootfastcgi_script_name;
include fastcgi_params;
}
是这个吗?

JellyBool 回复 big tree

看看有区别么:

 location ~ \.php$ {
	try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

格式对正一点

big tree 回复 JellyBool

http error 500
错误日志:*4 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/laravel/bootstrap/…/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/laravel/bootstrap/autoload.php on line 17
这是因为没有把/var/www/laravel/ 给到nginx? 但我已经按照视频执行了sudo chown -R www-data:www-data /var/www/laravel/

JellyBool 回复 big tree

需要执行 composer install

big tree 回复 JellyBool

composer安装过程中报了个错,好像不影响使用,[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process “git clone --no-checkout ‘https://github.com/sebastianbergmann/phpunit.git’ ‘/var/www/la
ravel/vendor/phpunit/phpunit’ && cd ‘/var/www/laravel/vendor/phpunit/phpunit’ && git remote add comp
oser ‘https://github.com/sebastianbergmann/phpunit.git’ && git fetch composer” exceeded the timeout
of 300 seconds.
又重新给了权限,还是不行

JellyBool 回复 big tree

PHP Warning: require(/var/www/laravel/bootstrap/…/vendor/autoload.php): failed to open stream

视频中直接部署代码的话,都是直接将 vendor 目录也提交上去了的。这个是关于 composer 的报错。

至于你的 nginx 的配置和权限问题

我觉得还是你的 nginx 没有配置对

big tree 回复 JellyBool

composer的问题解决后就都好了。还想问您一下,修改后的.vue文件git pull 之后并没有在线上生效是什么原因,已经执行过npm run dev,听说需要composer发布?

JellyBool 回复 big tree

你是在线上执行 npm run dev 还是在线下?线上环境使用 npm run prod,然后确保清除浏览器缓存

big tree 回复 JellyBool

线上线下都试过了,还是没反应

JellyBool 回复 big tree

确保清除浏览器缓存

big tree 回复 JellyBool

也已经清除了

JellyBool 回复 big tree

那我不知道了

big tree 回复 JellyBool

好的,谢谢!

big tree 回复 JellyBool

css文件修改后立即就可以生效,.vue文件修改后执行npm run production也没反应,这个是哪里的问题?

big tree 回复 JellyBool

非常感谢您能这么耐心的帮我解决问题!

big tree 回复 JellyBool

写上这个会报这个错 directive “location” has no opening “{” in /etc/nginx/sites-enabled/default:62

big tree 回复 JellyBool

3个地方的权限都给完并重启nginx之后的错误日志:directory index of “/var/www/laravel/” is forbidden, client: , server: _, request: “GET / HTTP/1.1”, host: “”

kounid

我配置nginx成功了,但是访问我的页面,没有Welcome to nginx为什么呢?

kounid

没有welcome to nginx而是无法访问我的页面,好像是有防火墙?

JellyBool 回复 kounid

这个看你用的哪家的机器,腾讯云好像默认就有防火墙

kounid 回复 JellyBool

我用的时Ucloud,我买的时候设置的非web服务器,后来改成web服务器就好了,还有我想问下老师怎么才能切换网页呢,我放在服务器上的网页无法切换。我发现我不能在服务器上更新我的网页

wgj416416

请问代码怎么更新,我现在更新代码就是先把之前的文件夹删掉,人后再重新git clone

JellyBool 回复 wgj416416

代码更新就直接 git pull 。。。我觉得你需要看看 git 的教程

wgj416416 回复 JellyBool

知道了,知道了!!!

940520

視頻掛了?為啥播放不了,手機,中國電信,4g

JellyBool 回复 940520

应该没挂的,可能是 cdn 的原因

GaoJun9521

用的ubuntu14.04系统,在service nginx restart时报 restarting nginx nginx 错误

JellyBool 回复 GaoJun9521

具体是什么错误呢?