博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php-msf 服务发现_PHP即服务-Fortrabbit
阅读量:2506 次
发布时间:2019-05-11

本文共 13471 字,大约阅读时间需要 44 分钟。

php-msf 服务发现

PaaS (platform as a service) is not a new concept. The fact of the matter is hosting companies have long since provided PaaS when they sell shared-hosting services that include PHP on the shared server. This is fundamentally different, however, from how a PaaS business works.

PaaS(平台即服务)不是一个新概念。 事实是,托管公司在出售共享服务器上的包含PHP的共享托管服务时早就提供了PaaS。 但是,这与PaaS业务的工作方式根本不同。

In this article, we’ll take a look at a newcomer to the platform service provider arena – Fortrabbit – and set up a simple PHP/MySQL application that can be publicly accessed in a matter of minutes.

在本文中,我们将介绍平台服务提供商领域的新手Fortrabbit,并建立一个简单PHP / MySQL应用程序,该应用程序可在几分钟之内公开访问。

Basic knowledge of the LAMP stack is assumed, and you also need to have a basic grasp of Git (if you don’t ), and you need to have SSH keys generated and ready for use (if you don’t, refer to ). This walk-through is Unix oriented (so OS X and Linux users are fine), but it can also be applied to a Windows environment with minor changes.

假定您已具备LAMP堆栈的基本知识,并且还需要对Git有基本的了解(如果您不了解, ),并且需要生成SSH密钥并准备使用(如果您不知道) ,请参阅 )。 本演练是面向Unix的(因此OS X和Linux用户都可以使用),但也可以将其应用于Windows环境,而只需进行少量更改。

Fortrabbit –谁,为什么以及如何 (Fortrabbit – the Who, Why, and How)

Fortrabbit is a young PaaS company who say the hosting business is broken, and too much about price dumping and too little about quality. In order to fix the problem, they made a PHP-exclusive business that caters to developers’ most common needs. Their hosting plans are accessibly-tiered for everyone, from hobbyists (free plans) to enterprises (high-availability upgrades are available at the click of a button).

Fortrabbit是一家年轻的PaaS公司,他说托管业务已破裂,对价格倾销的关注太多,而对质量的关注却很少。 为了解决该问题,他们开展了PHP专属业务,以满足开发人员的最常见需求。 从爱好者(免费计划)到企业,每个人的托管计划都可以访问分层(只需单击一个按钮,即可进行高可用性升级)。

With a single dashboard, you have an overview of all your applications, regardless of your role in them.

使用单个仪表板,您可以概览所有应用程序,无论您在其中扮演什么角色。

alt

Applications can be made publicly visible whenever you choose to deploy, so you can easily demonstrate what you’re building to your clients whenever you want. Once an application is complete, you can transfer ownership to the client, who then becomes in charge of payments from that point onward. You can even retain a “Project Manager” role on the application to be able to perform future fixes and upgrades. The whole freelancing process is literally streamlined into minutes.

每当您选择部署时,应用程序都可以公开可见,因此您可以随时随地轻松地向客户端演示正在构建的内容。 申请完成后,您可以将所有权转让给客户,然后客户从该点开始负责付款。 您甚至可以在应用程序上保留“项目经理”角色,以执行将来的修复和升级。 从字面上看,整个自由职业过程简化为几分钟。

Deploying works with Git, SSH, SFTP, ReSync, and Composer. You have full SSH access to your application and can play around with it however you see fit. Frameworks and content management systems are supported and easily installable out of the box, and support is coming soon now available too (version 0.9)!

部署可与Git,SSH,SFTP,ReSync和Composer一起使用。 您具有对应用程序的完全SSH访问权限,并且可以随意使用它。 支持框架和内容管理系统,并且易于安装,并且支持是 快来了 现在也可用(0.9版)!

演示应用 (The demo app)

Let’s get a simple Hello World application up and running. Clone the from Github. It’s nothing but a simple CodeIgniter skeleton application, slightly modified for our purposes here. The controller reads the URL input to find an ID parameter, and if it finds none, it sets it to 1, otherwise, it uses the one provided. This ID parameter dictates which database row we fetch, and thus whether the output will print “Hello World” or “Hello Bruno”.

让我们启动并运行一个简单的Hello World应用程序。 从Github克隆 。 它只不过是一个简单的CodeIgniter骨架应用程序,出于此处的目的进行了一些修改。 控制器读取URL输入以查找ID参数,如果找不到,则将其设置为1,否则将使用提供的ID。 此ID参数指示我们要提取哪个数据库行,并因此决定输出将输出“ Hello World”还是“ Hello Bruno”。

See the db directory for the SQL import script create a database called “sitepoint”. Also, modify the database.php file in the application/config directory accordingly so your app can access the database. In my case, the username is root, and I have no password.

有关SQL导入脚本的信息,请参见db目录。创建一个名为“ sitepoint”的数据库。 另外,相应地修改application/config目录中的database.php文件,以便您的应用程序可以访问数据库。 就我而言,用户名是root,我没有密码。

Test the application by creating a virtual host for it. For the sake of example, let’s assume you named the host fortrabbit.sitepoint.test. Thus, entering fortrabbit.sitepoint.test/ into your browser should say “Hello World!” and fortrabbit.sitepoint.test/welcome/index/id/2 should say “Hello Bruno!”. All good? Great! Let’s cloud it up.

通过为其创建虚拟主机来测试应用程序。 为了举例说明,假设您将主机命名为fortrabbit.sitepoint.test 。 因此,在浏览器中输入fortrabbit.sitepoint.test /时应显示“ Hello World!”。 和fortrabbit.sitepoint.test / welcome / index / id / 2应该说“你好,布鲁诺!”。 都好? 大! 让我们把它笼罩起来。

设置Fortrabbit应用程序 (Setting up a Fortrabbit Application)

Go to Fortrabbit and sign up for an account. Once you have an account, proceed to click the New App button on the dashboard:

转到Fortrabbit并注册一个帐户。 拥有帐户后,继续单击仪表板上的“新建应用程序”按钮:

alt

Select the Bootstrap Free plan on the next screen and click Purchase. Note the “freeze” limitation – after a certain amount of inactivity, you app will become frozen and unavailable and you’ll have to log back in to “thaw” it. This is to both conserve resources and prevent users from hogging their services without paying. Consider it an unlimited free trial.

在下一个屏幕上选择免费引导程序,然后单击购买。 请注意“冻结”限制-一定量的不活动后,您的应用将变为冻结且不可用,您必须重新登录才能“解冻”它。 这既可以节省资源,又可以防止用户浪费自己的服务而不付费。 认为它是无限的免费试用。

On the next screen, enter an app name and your public SSH key. We’ll need this to push our app live. See the following figure for reference.

在下一个屏幕上,输入应用名称和您的公共SSH密钥。 我们将需要使用它来推动我们的应用程序上线。 请参见下图以供参考。

alt

You’ll have to wait for the setup to complete on the next screen, and a couple of minutes later for your app to be ready. You’ll receive an email with all the necessary credentials and URLs to manage and visit your application. In fact, visiting the Test URL from the email/final configuration screen will produce a screen not unlike this one:

您必须等待设置在下一个屏幕上完成,几分钟后才能准备好您的应用程序。 您会收到一封电子邮件,其中包含所有必要的凭据和URL,以管理和访问您的应用程序。 实际上,从电子邮件/最终配置屏幕访问“测试URL”将产生一个与以下内容相同的屏幕:

alt

A full report of the stack you’re running is shown, a working application ready to be turned into something useful.

显示了您正在运行的堆栈的完整报告,可以正常工作的应用程序可以变成有用的东西。

仪表板 (Dashboard)

The app dashboard Fortrabbit takes you to after you click “Take me to my app” on the final configuration screen is where proper management takes place. Here you can see how much time you have until the app is frozen, and can reset the timer at will. All you do by doing that is prove your activity and the app stays alive, simple as that. The strength and cost of your app’s plan are defined here as well, along with some quick stats and a list of purchased add-ons (e.g. Memcache is an add-on you need to pay extra for).

在最终配置屏幕上单击“将我带到我的应用程序”后,应用程序仪表板Fortrabbit会将您带到适当的管理位置。 在这里,您可以看到冻结应用程序有多长时间,并且可以随意重置计时器。 您所做的所有事情就是证明您的活动,这样应用程序才能保持活跃,就这么简单。 还定义了应用程序计划的强度和成本,以及一些快速统计信息和已购买的附件列表(例如,Memcache是​​您需要额外付费的附件)。

alt

The stats tab will give you a detailed overview of your app’s performance, and the Git tab lets you revisit the public SSH key input from the initial configuration.The SSH/SFTP tab simply lists access credentials.

stats选项卡将为您提供有关应用程序性能的详细概述,而Git选项卡可让您从初始配置中重新访问公共SSH密钥输入。SSH/ SFTP选项卡仅列出访问凭据。

The PHP tab lets you set some configuration directives and PHP options and the domains tab provides an easy access to defining new domains and subdomains so you can have a custom domain point to your application and get rid of the long eu.frbit suffix. There is also the permissions tab which lets you define a new owner for the application for the purposes of a transfer, add team members, and more (the free bootstrap plan only supports a one-man operation though).

“ PHP”选项卡允许您设置一些配置指令和PHP选项,而“域”选项卡使您可以轻松地定义新的域和子域,因此您可以为应用程序添加自定义域,并摆脱了冗长的eu.frbit后缀。 还有一个“权限”选项卡,您可以使用该选项卡为应用程序定义新所有者,以进行转移,添加团队成员等(免费的引导计划仅支持单人操作)。

部署中 (Deploying)

Fortrabbit, being young, still does’t have a web GUI for MySQL installed, so no PHPMyAdmin. You can, of course, install your own – but there’s another option that’s quite practical. MySQL Workbench supports remote tunnel connections via SSH, so assuming you have it installed (and you really should have it installed), open a new connection and define all the required parameters:

年轻的Fortrabbit仍然没有安装MySQL的Web GUI,因此没有PHPMyAdmin。 您当然可以安装自己的–但是还有另一种非常实用的选择。 MySQL Workbench支持通过SSH进行远程隧道连接,因此,假设您已安装(并且确实应该安装),请打开一个新连接并定义所有必需的参数:

alt

Now you have access to your remote database via a local client – and editing the database could not be easier. Since the Fortrabbit MySQL user/pass combo is different from our local setup, we need a way to accommodate this without having to constantly update the database configuration. Luckily there’s an easy way to do this as well. At the end of application/config/database.php, we placed the following code (replace your username and password accordingly):

现在,您可以通过本地客户端访问远程数据库,并且编辑数据库再简单不过了。 由于Fortrabbit MySQL用户/密码组合与我们的本地设置不同,因此我们需要一种无需不断更新数据库配置即可适应的方法。 幸运的是,还有一种简单的方法可以做到这一点。 在application/config/database.php的末尾,我们放置了以下代码(相应地替换用户名和密码):

if (isset($_SERVER['APP_NAME'])) { // This means we're on Fortrabbit, and need different credentials. // Local setups don't have the "APP_NAME" environment variable $db['default']['hostname'] = 'sitepoint.mysql.eu1.frbit.com'; $db['default']['username'] = 'sitepoint'; $db['default']['password'] = 'xxxxxxxx';}

This works because Fortrabbit defines an environment variable for every app called APP_NAME which we don’t have on our local machine. Whenever we’re testing locally, our app accesses the local database as it did before. When we test online, the username, password, and host switch to the Fortrabbit credentials. Note that you can define an arbitrary amount of environment variables in the app’s dashboard under the PHP tab.

这之所以有效,是因为Fortrabbit为我们本地计算机上没有的每个名为APP_NAME应用程序定义了一个环境变量。 每当我们在本地进行测试时,我们的应用程序都会像以前一样访问本地数据库。 当我们在线测试时,用户名,密码和主机将切换到Fortrabbit凭据。 请注意,您可以在PHP选项卡下的应用程序仪表板中定义任意数量的环境变量。

The next step is importing the SQL file into the database. With our connection to MySQL still open, import the provided SQL file from the db folder.

下一步是将SQL文件导入数据库。 在我们与MySQL的连接仍然打开的情况下,从db文件夹导入提供SQL文件。

Now let’s finally deploy our application. This is done in several steps and has multiple possible approaches; we’ll cover only one.

现在,让我们最后部署我们的应用程序。 这是分几个步骤完成的,有多种可能的方法。 我们只覆盖一个。

第1步:克隆当前的Fortrabbit应用 (Step 1: Clone your current Fortrabbit app)

In the terminal, enter git clone git@git1.eu1.frbit.com:sitepoint.git which will clone an empty repository from your Fortrabbit app. It might be strange that the repo is empty when in fact you see some content when you visit the app’s URL, but this is because there’s a hidden index.php file inside it already that’s initially ignored. As soon as you push the first commit, this index.php file is overwritten (if you added such a file in the root of your project, that is).

在终端中,输入git clone git@git1.eu1.frbit.com:sitepoint.git ,这将从您的Fortrabbit应用程序中克隆一个空的存储库。 当您实际上在访问应用程序的URL时看到一些内容时,回购是空的,这可能很奇怪,但这是因为里面已经存在一个隐藏的index.php文件,该文件最初已被忽略。 按下第一次提交后,此index.php文件将被覆盖(也就是说,如果您在项目的根目录中添加了这样的文件)。

步骤2:将内容添加到文件夹,添加到Git (Step 2: Add content to folder, add to Git)

Next, we take the entire content of our local application and just move it into this directory. Then add the contents of the directory to the repository with the following command: git add *, and of course, make a commit (git commit -am 'Initial commit')

接下来,我们将获取本地应用程序的全部内容,然后将其移至该目录中。 然后使用以下命令将目录的内容添加到存储库中: git add * ,当然要进行提交( git commit -am 'Initial commit' )

第3步:实时推送应用 (Step 3: Push the app live)

Use the git push origin master command to push your application live. The origin master part is only required on first push – subsequent pushes do not require it.

使用git push origin master命令将应用程序实时发布。 仅在第一次推送时才需要origin master部件–后续推送则不需要它。

步骤4:变更网域设定 (Step 4: Change the domain setting)

In the “Manage app” screen under the domains tab, add public after the original URL in the input field, like so:

在“域”标签下的“管理应用”屏幕中,在输入字段中原始URL后面添加public ,如下所示:

alt

This is so the server looks for the application root inside public, instead of the unavailable top folder.

这样一来,服务器将在public而不是不可用的顶层文件夹中查找应用程序根目录。

That’s it! Visit your app now via its URL and you should see it work just as it does locally. Append the URL part with the parameters (/welcome/index/id/2) and see the string change. This shows us that both URL rewriting and the database connection work as they should.

而已! 现在通过其URL访问您的应用,您应该会看到它像在本地一样工作。 在网址部分附加参数( / welcome / index / id / 2 ),然后查看字符串更改。 这向我们展示了URL重写和数据库连接都可以正常工作。

免费赠送 (Free Give Away)

In a sea of *aaS services, Fortrabbit stands out with usability, simplicity, approachability and a heavily involved staff that are there for you every step of the way. In this generous and ambitious spirit, Fortrabbit is teaming up with SitePoint for an awesome give away!

在* aaS服务的海洋中,Fortrabbit在可用性,简单性,可访问性和高度参与的员工中脱颖而出,为您提供一站式服务。 秉承这种慷慨和雄心勃勃的精神,Fortrabbit与SitePoint携手合作,进行了令人敬畏的奉献!

Five lucky readers will win coupon codes worth 100€ redeemable for Fortrabbit service. To be eligible, 1) and post a comment below letting us know your experiences, or 2) follow and share this article on Twitter with the hashtag #phpmaster, all by February 20th. Five winners will be chosen at random shortly thereafter. Comment winners will be notified by email (be sure to provide a valid email address in the contact-form!) and Twitter winners by direct-message.

五位幸运的读者将赢得价值100欧元的Fortrabbit服务可兑换的优惠券代码。 要获得参赛资格,请执行以下操作:1) 并在下面发表评论以让您了解您的经历,或者2)关注并在2月20日之前在Twitter上使用#phpmaster标签共享本文。 此后不久将随机选出5名优胜者。 评论优胜者将通过电子邮件(请确保在联系表中提供有效的电子邮件地址!)得到通知,Twitter优胜者将通过直接消息得到通知。

Good luck!

祝好运!

翻译自:

php-msf 服务发现

转载地址:http://vlrgb.baihongyu.com/

你可能感兴趣的文章
【NOI 2018】归程(Kruskal重构树)
查看>>
注册用户
查看>>
TZC Intercommunication System
查看>>
HDU 4571 SPFA+DP
查看>>
centos 创建以日期为名的文件夹
查看>>
Java Timer触发定时器
查看>>
Page Object设计模式
查看>>
程序的基础知识
查看>>
在VIM中使用GDB调试 – 使用vimgdb
查看>>
python爬虫---从零开始(五)pyQuery库
查看>>
POJ2236(KB5-A)
查看>>
Centos MySQL数据库迁移详细步骤
查看>>
2初出茅庐--初级篇2.1
查看>>
新建 WinCE7.0 下的 Silverlight 工程
查看>>
腾讯的张小龙是一个怎样的人?
查看>>
jxl写入excel实现数据导出功能
查看>>
linux文件目录类命令|--cp指令
查看>>
.net MVC 404错误解决方法
查看>>
linux系统目录结构
查看>>
git
查看>>