简体   繁体   English

尝试从我的本地计算机上在客户的Drupal站点上工作

[英]Trying to work on a client's Drupal site from my local machine

I have a client who wants me to update their Drupal site. 我有一个客户希望我更新其Drupal网站。 I've never done this before, and I want to work on it from my local machine just in case something goes wrong. 我以前从未做过此事,并且我想从本地计算机上进行处理,以防万一出问题。 I have no idea where to even start! 我什至不知道从哪里开始!

First off, how do I access my client's site files so I can get them onto my computer? 首先,如何访问客户的站点文件,以便可以将其下载到计算机上? I've tried entering the information the client gave me into Cyberduck, but it won't give me access. 我曾尝试输入客户给我的信息到Cyber​​duck,但不会给我访问权限。 Is there another way to get access? 还有另一种获取访问权限的方法吗?

Also, how do I host it locally? 另外,如何在本地托管它? I have XAMPP, but I'm not sure how to use it. 我有XAMPP,但不确定如何使用。

That being said, I have found a few forums that should help me set up the local server. 话虽如此,我发现了一些论坛可以帮助我设置本地服务器。 I just don't know how to get the files from the live server to my computer. 我只是不知道如何将文件从实时服务器发送到我的计算机。

I know this is a super noob problem, but I could use the help. 我知道这是一个超级菜鸟问题,但是我可以使用帮助。 Thank you! 谢谢!

Well, for the basic question, you have to get the correct credentials from your client. 好吧,对于基本问题,您必须从客户那里获得正确的凭据。 There's no alternative, really :D 别无选择,真的:D

While you're at it, you'll want a copy of the site's database too. 在使用它时,您也将需要该站点数据库的副本。

For the question "how do I host it locally?" 对于“如何在本地托管它”问题。 Here's how I would go about it. 这就是我要做的。

Get the site into version control. 使站点进入版本控制。

Given that you were given (S)FTP credentials, I'm guessing the site is not version-controlled. 假定您已获得(S)FTP凭据,我猜该站点不受版本控制。 If that's correct, then that is probably the very first thing you want to do. 如果是正确的话,那可能就是您要做的第一件事 This will allow you to keep track of the changes you've made on your local site that are different to the production version. 这样,您就可以跟踪在本地站点上所做的与生产版本不同的更改。

  1. Create an empty directory on your computer. 在您的计算机上创建一个空目录。
  2. Navigate to the directory in a terminal and run git init . 导航到终端中的目录,然后运行git init
  3. Add a .gitignore file to that folder (you can create your own, or use one customized for Drupal ). .gitignore文件添加到该文件夹​​(您可以创建自己的文件,也可以使用为Drupal自定义的文件 )。
  4. Download the site's files into the directory created in step 1. 将站点的文件下载到步骤1中创建的目录中。
  5. Add the files from the in the directory to the git repository by running this command in a terminal: git commit -am "First commit of Drupal files to repository." 通过在终端上运行以下命令,将目录中的文件添加到git存储库: git commit -am "First commit of Drupal files to repository."

There's a good help page about working with Drupal in git on drupal.org . 在drupal.org上有一个关于在git中使用Drupal的好帮助页面

Create and populate your database. 创建并填充数据库。

  1. Get a database dump from the live site. 从实时站点获取数据库转储。
  2. Create a new database and database user on your machine. 在您的计算机上创建一个新的数据库和数据库用户。
  3. Import the database dump into your new database. 将数据库转储导入到新数据库中。
  4. Record the database credentials in settings.php or settings.local.php and store them somewhere safe, preferably in a password manager. 将数据库凭据记录在settings.phpsettings.local.php ,并将它们存储在安全的位置,最好存储在密码管理器中。
  5. Change the database credentials in settings.php or settings.local.php to match the credentials of the database you've just created. settings.phpsettings.local.php更改数据库凭据,以匹配刚刚创建的数据库的凭据。

    (For safety and to avoid confusion, I always create local databases with a different name, user, and password than the live site has. This means if your local credentials are compromised, the live site isn't, and it means you can't connect to and change the live site's database by accident .) (为安全起见,为避免混淆,我始终使用与实时站点不同的名称,用户和密码来创建本地数据库。这意味着如果本地凭据受到破坏,则实时站点不会受到损害,这意味着您可以t 偶然连接并更改实时站点的数据库。)

Set up the webserver in XAMPP 在XAMPP中设置Web服务器

  1. Create a new site in XAMPP called eg example.local that points to the directory that contains the file index.php 在XAMPP中创建一个名为example.local的新站点,该站点指向包含文件index.php的目录。
  2. Add the following line the file called /etc/hosts on your computer: 将以下行添加到您计算机上名为/etc/hosts的文件中:

    127.0.0.1 example.local

  3. Test that this works in a browser by visiting eg http://example.local or http://example.local/robots.txt . 通过访问例如http://example.localhttp://example.local/robots.txt测试其是否在浏览器中有效。

Move your local changes to the Production site 将本地更改移至生产站点

How you will be able to do this depends to some extent on your client's web-hosting infrastructure, and what version of Drupal your client uses. 如何执行此操作在一定程度上取决于客户端的Web托管基础结构以及客户端使用的Drupal版本。 but in any case, you will have three separate concerns for changes you make: 但无论如何,您将对所做的更改有三个单独的关注点:

  1. Code changes 代码变更

    You will need to deploy changes you make to the code back to the server. 您将需要将对代码所做的更改部署回服务器。 Ideally you would probably do this via Git either by cloning directly into the live site or (far better!) as part of an automated build process. 理想情况下,您可能会通过直接克隆到实时站点中或(作为更好的方法)作为自动化构建过程的一部分,通过Git进行此操作。 By the sound of it, you may just have to FTP the changes back up. 听起来,您可能只需要通过FTP将更改备份。

    Be careful not to re-upload your modified settings.php or settings.local.php file! 注意不要重新上传修改后的settings.phpsettings.local.php文件!

  2. Content changes 内容变更

    You probably have to test some/all of your content changes locally and then recreate them on the live site. 您可能必须在本地测试部分/全部内容更改,然后在实时站点上重新创建它们 Because your client may have made changes to the live site while you were working, you can't risk importing your local database into the live site. 由于您的客户可能在工作时对实时站点进行了更改,因此您不必冒险将本地数据库导入实时站点。

  3. Configuration changes 配置变更

    Changes to configuration should be managed in code (ie as part of 1. Code changes above) if that's possible. 如果可能的话,应该使用代码来管理对配置的更改(即,作为上述1.代码更改的一部分)。 In Drupal 7, the Features module is usually the best way to accomplish this (here's an answer I wrote describing the Features workflow ). 在Drupal 7中, 功能模块通常是实现此目的的最佳方法(这是我写的描述功能工作流的答案 )。 Drupal 8 has the Configuration Manager . Drupal 8具有配置管理器 Be aware that these two tools can both be tricky to use well. 请注意,这两种工具都很难很好地使用。

Your client needs to gave you access to the files so you can put them into htdocs on XAMPP, then you need the database (also provide by the client), start XAMPP, create a new database on localhost/phpMyAdmin and import the db of the site. 您的客户端需要让您访问文件,以便可以将它们放入XAMPP上的htdocs中,然后您需要数据库(也由客户端提供),启动XAMPP,在localhost/phpMyAdmin上创建新数据库并导入数据库的数据库。现场。 On the proyect code go to sites/default/settings and change the db settings to your local settings. 在proyect代码上,转到sites/default/settings然后将db设置更改为本地设置。 Then you can go to localhost/{your-proyect} and it should work. 然后,您可以转到localhost/{your-proyect} ,它应该可以工作。

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

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