简体   繁体   English

如何将 Laravel 项目部署到共享服务器

[英]How to deploy Laravel project in to shared server

I have a Laravel project, I want to deploy it into the server, the thing is that normally we have index.php and .htaccess inside the public folder, but in my case, I have brought these two files into the root.我有一个 Laravel 项目,我想将它部署到服务器中,问题是通常我们有 index.php 和 .htaccess 在公共文件夹中,但在我的情况下,我将这两个文件带入了公共文件夹中。 So I want to know, what are the changes needed in serve?所以我想知道,服务中需要进行哪些更改?

How can I upload this to server?如何将其上传到服务器?

Solution 1 Somehow you need to get the ssh access as a shared user from your hosting provider and then you can use git to clone your repository into your server.解决方案 1您需要以某种方式从托管服务提供商处以共享用户的身份获取ssh 访问权限,然后您可以使用git您的存储库克隆到您的服务器中。

Solution 2 You can copy paste all of your project into the server using ftp from your cpanel or relevant control panel.解决方案 2您可以从您的 cpanel 或相关控制面板使用 ftp 将所有项目复制粘贴到服务器中。

Solution 3 Use Amazon as your hosting as it gives 1 year free tier access, and also gives you ssh service.解决方案 3使用亚马逊作为您的主机,因为它提供 1 年免费层级访问,还为您提供 ssh 服务。 Follow the solution 1 after getting this.得到这个后按照解决方案1。

Put back the files to the public folder.将文件放回公用文件夹。 You can change the root path of your server to your project's public folder.您可以将服务器的根路径更改为项目的公用文件夹。

Follow the steps to do:请按照以下步骤操作:

  1. Go to /etc/apache2/sites-enabled/ Go 到/etc/apache2/sites-enabled/
  2. Open the .conf file inside this folder打开此文件夹中的.conf文件
  3. Change the docuementRoot to /etc/var/www/html/project_name/public文档根更改为/etc/var/www/html/project_name/public

Restart the apache server using the following command:使用以下命令重启 apache 服务器:

sudo systemctl restart apache2 sudo systemctl restart apache2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM