简体   繁体   English

如何将本地Laravel项目移至AWS服务器?

[英]How do I move a local Laravel project to an AWS server?

I have a localhost Laravel project running on Windows 10 with XAMPP, and everything's working fine. 我有一个使用XAMPP在Windows 10上运行的localhost Laravel项目,一切正常。 I now want to move this project to AWS so that I can share it with other people. 我现在想将此项目移至AWS,以便与其他人共享。

Specifically, I want to put it on an EC2 server with Apache and PHP 7.0+, and then put the MariaDB instance on an RDS instance that I'll connect to. 具体来说,我想将其放在带有Apache和PHP 7.0+的EC2服务器上,然后将MariaDB实例放在我将连接到的RDS实例上。

I know how to set up an EC2 instance and an RDS instance. 我知道如何设置EC2实例和RDS实例。 I also know how to set up the MariaDB instance an edit the .env file to point to the RDS MariaDB instance. 我也知道如何设置MariaDB实例以及编辑.env文件以指向RDS MariaDB实例。

What I don't know how to do though is move / set up the Laravel project on the EC2 instance so that all of my files are there and when I go to the IP address of the EC2 instance, it loads the root controller (ie, Route::get('/', function () { ... }) ). 我不知道该怎么办,是在EC2实例上移动/设置Laravel项目,以便所有文件都在那里,当我转到EC2实例的IP地址时,它将加载根控制器(即, Route::get('/', function () { ... }) )。

My thought process was to move everything over so that the public folder of my Laravel project matched up with the /var/www/html/ directory on the server, but maybe that's not right. 我的思维过程是所做的一切运动,使得public与匹配我的Laravel项目的文件夹中/var/www/html/服务器上的目录,但也许这是不正确的。

Also, should I copy all the npm/composer files over from my local project to the server (via FTP, etc.), or should I skip those and then run an npm install and composer install (sorry, don't recall the exact command) once all the other files are on the server? 另外,我应该将所有npm / composer文件从本地项目复制到服务器上(通过FTP等),还是应该跳过这些文件,然后运行npm installcomposer install (对不起,不记得确切的信息了)命令)一旦所有其他文件都在服务器上?

Do I need to edit the Apache config to get things working? 我是否需要编辑Apache配置才能正常工作? How? 怎么样? What kind of file permissions need to possibly be set? 可能需要设置哪种文件许可权?

These are the main questions I have, but I may be missing other stuff as well. 这些是我的主要问题,但我可能还会缺少其他内容。 Thank you. 谢谢。

You will have to set the document root equal to the public folder of your project. 您将必须将文档根目录设置为等于项目的公用文件夹。 So normally the site will be at /var/www/yoursite/ and the document root in your apache config will be /var/www/yoursite/public . 因此,通常该站点位于/var/www/yoursite/ ,而您的apache配置中的文档根目录将为/var/www/yoursite/public That way the route '/' will be your public folder. 这样,路由'/'将成为您的公用文件夹。 The /var/www/html folder will be the default document root of apache which must be left alone. /var/www/html文件夹将是apache的默认文档根目录,必须将其保留。 In the folder /var/www/yoursite you can pull your changes from github and then run composer install and npm install . 在文件夹/var/www/yoursite您可以从github提取更改,然后运行composer installnpm install

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

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