蛇呆在树上,整天无所事事_指南:如何在无所事事的盒子上安装OroCRM

蛇呆在树上,整天无所事事

OroCRM is a CRM application we’ll be describing in a post dedicated to it tomorrow. This guide merely covers its installation and first run on a Vagrant Box – in particular, our good old Homestead Improved. If you need to get up and running with Homestead, see the original Quick Tip. If you want to follow along with tomorrow’s post on OroCRM, get a head start by installing it with the procedures below!

OroCRM是一个CRM应用程序,我们将在明天专门针对它的帖子中进行介绍。 本指南仅介绍其安装和首次在Vagrant Box上运行-尤其是我们的老式Homestead改进版。 如果您需要使用Homestead来启动和运行,请参阅原始的Quick Tip 。 如果您想跟随明天在OroCRM上发布的帖子,请按照以下步骤安装它,从而抢先一步!

安装 (Installation)

Before we begin, make sure your original Homestead Improved instance is working well, then destroy it. If you want symlink support and are on Windows, re-run the command prompt and/or Git Bash window through which you’ll be using Vagrant commands with Administrator privileges:

在开始之前,请确保您原来的Homestead Improvementd实例运行良好,然后销毁它。 如果要在Windows上支持符号链接,请重新运行命令提示符和/或Git Bash窗口,通过该窗口将使用具有管理员特权的Vagrant命令:

alt

This is optional – symlinks are not required for Oro to work.

这是可选的– Oro正常工作不需要符号链接。

步骤1:添加网站 (Step 1: Add a Site)

In Homestead.yaml, add the site:

Homestead.yaml ,添加站点:

- map: test.app
      to: /home/vagrant/Code/orocrm/web

The web subfolder is needed due to Symfony being the foundation Oro is built upon.

由于Symfony是Oro的基础,因此需要web子文件夹。

To make sure Symfony can write into its parent folders, we need to alter the mount mode of the shared folders. In scripts/homestead.rb update the following line from:

为了确保Symfony可以写入其父文件夹,我们需要更改共享文件夹的安装模式。 在scripts / homestead.rb中,从以下位置更新以下行:

config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil

to

config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil, :mount_options => ["dmode=777,fmode=777"]

This is the last operation we’ll do outside the VM. Enter it now with vagrant ssh after running vagrant up.

这是我们将在VM外部执行的最后一项操作。 在运行vagrant up之后,现在使用vagrant ssh输入它。

步骤2:克隆 (Step 2: Clone)

cd Code
git clone http://github.com/orocrm/crm-application.git orocrm

步骤3:创建数据库 (Step 3: Create the Database)

mysql -u homestead -psecret
CREATE SCHEMA `oro_crm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

步骤4:配置Nginx和PHP (Step 4: Configure Nginx and PHP)

The configuration required for OroCRM in this case is as follows (replace the folder paths with your own if necessary). Put this into /etc/nginx/sites-available/test.app, replacing the original content:

在这种情况下,OroCRM所需的配置如下(如果需要,请用您自己的文件夹路径替换)。 将其放入/etc/nginx/sites-available/test.app ,替换原始内容:

server {
        listen 80;
        server_name test.app;
        root /home/vagrant/Code/orocrm/web;

        index app.php;

        access_log /var/log/nginx/test.app.access_log;
        error_log /var/log/nginx/test.app.error_log info;

	    location = /favicon.ico { access_log off; log_not_found off; }
	    location = /robots.txt  { access_log off; log_not_found off; }

        try_files $uri $uri/ @rewrite;
	    sendfile off;
	    
        location @rewrite { rewrite ^/(.*)$ /app.php/$1; }

        location ~ [^/]\.php(/|$) {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                if (!-f $document_root$fastcgi_script_name) {
                        return 404;
                }
                fastcgi_index app.php;
                fastcgi_read_timeout 10m;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
				include fastcgi_params;
		}
}

Don’t forget to restart Nginx with sudo service nginx restart.

不要忘记使用sudo service nginx restart重启Nginx。

Due to some bugs in either Composer, or the way the dependencies are set up, we need to raise the limit of RAM use for PHP’s command line instance to 1G. The VM we’re running has a reserved 2G, so that’s no problem.

由于Composer中的某些错误或依赖项的设置方式,我们需要将PHP命令行实例的RAM使用限制提高到1G。 我们正在运行的VM具有保留的2G,所以这没问题。

sudo vim /etc/php5/cli/php.ini

Once in the file, hit the forward slash button if you’re using Vim to enter search mode, type “memory” and hit enter to get to the line that says 512M. Enter insert mode with “i” and replace “512M” with “1G”. Save and exit.

进入文件后,如果您使用Vim进入搜索模式,请点击正斜杠按钮,键入“ memory”,然后按Enter进入显示512M的行。 用“ i”进入插入模式,用“ 1G”代替“ 512M”。 保存并退出。

Next, we need to activate pathinfo in php-fpm, as per this StackOverflow answer.

接下来,根据此StackOverflow答案 ,我们需要在php-fpm中激活pathinfo。

sudo vim /etc/php5/fpm/php.ini

Search for the line cgi.fix_pathinfo and set the value to 1. Also increase the maximum execution time for PHP scripts to 300 instead of 30 (search for max_execution), because Symfony apps are incredibly overbloated and need a long time on first requests to generate the cache they then use on subsequent runs.

搜索cgi.fix_pathinfo行并将其值设置为1。还将PHP脚本的最大执行时间增加到300,而不是30(搜索max_execution ),这是因为Symfony应用程序令人难以置信地过度膨胀,并且在第一次生成请求时需要很长时间然后在后续运行中使用的缓存。

Finally, there’s one more tweak we need to do.

最后,我们还需要进行另一项调整。

sudo vim /etc/php5/mods-available/xdebug.ini

Add the line xdebug.max_nesting_level = 1000 to this file. We do this because Xdebug chokes out on the default nesting level of 100 when dealing with Symfony’s bloat. With this, we let it “go deeper”. Save and exit, and restart php5-fpm (sudo service php5-fpm restart).

xdebug.max_nesting_level = 1000行添加到此文件。 我们这样做是因为Xdebug在处理Symfony的膨胀时会阻止默认的嵌套级别100。 这样,我们就让它“更深入”。 保存并退出,然后重新启动php5-fpm( sudo service php5-fpm restart )。

We also need the php-intl extension installed, as with most Symfony projects.

与大多数Symfony项目一样,我们还需要安装php-intl扩展名。

sudo apt-get update
sudo apt-get install php5-intl

步骤5:作曲家 (Step 5: Composer)

First, let’s speed up Symfony. Go into app/AppKernel.php and add the following two methods to the class:

首先,让我们加快Symfony的速度。 进入app/AppKernel.php并将以下两个方法添加到类中:

public function getCacheDir()
    {
        if (in_array($this->environment, array('dev', 'test', 'prod'))) {
            return '/dev/shm/appname/cache/' .  $this->environment;
        }

        return parent::getCacheDir();
    }

    public function getLogDir()
    {
        if (in_array($this->environment, array('dev', 'test', 'prod'))) {
            return '/dev/shm/appname/logs';
        }

        return parent::getLogDir();
    }

As per this post, this moves the logs and cache folders outside the shared guest/host folder, and keeps the IO operations inside the VM. Symfony is notorious for super-high IO, and having those folders remain in their default place is a death sentence for any Symfony project on Vagrant.

按照这篇文章 ,这会将日志和缓存文件夹移到共享的guest / host文件夹之外,并将IO操作保留在VM内。 Symfony因超高IO而臭名昭著,对于Vagrant上的任何Symfony项目,将这些文件夹保留在其默认位置都是死刑。

Finally, let’s install the CRM’s dependencies.

最后,让我们安装CRM的依赖项。

cd orocrm
export COMPOSER_PROCESS_TIMEOUT=3000; composer install --prefer-dist --no-dev

The “export” command before the “install” command is there to make sure Composer keeps going even if it encounters an insanely large repo. The prefer dist option means the dependencies aren’t downloaded as sources under version control, but as just sources or a phar package even. When --prefer-sources is used (default), the entire version tree is downloaded too, which slows down the download and increases the amount of disk space required, which is pointless if you don’t intend to hack away on the actual dependencies.

在“安装”命令之前的“导出”命令可以确保Composer继续运行,即使遇到疯狂的大型仓库也是如此。 Preferred dist选项意味着依赖项不会在版本控制下作为源下载,甚至仅作为源或phar包下载。 当使用--prefer-sources (默认)时,也会下载整个版本树,这会减慢下载速度并增加所需的磁盘空间,如果您不打算破解实际的依赖项,这将毫无意义。 。

During installation (which will take upwards of 30 minutes easily due to the sheer bloat of Symfony’s dependencies), you will be asked for your username and password for Github due to their anonymous download rate limitation policy. This is nothing to be concerned about. At the end of the download, you’ll be asked for some configuration params regarding the database, mailer, etc.

在安装过程中(由于Symfony的依赖关系突然膨胀,可能最多需要30分钟的时间),由于其匿名下载速率限制政策,系统会要求您输入Github的用户名和密码。 这没什么可担心的。 下载结束时,系统将要求您提供有关数据库,邮件程序等的一些配置参数。

alt

Then, run php app/console oro:install --env dev to install the app completely or visit http://test.app:8000 in your host machine’s browser. This will take another 10 minutes or so, but it’s the final step. For some reason, setting the --env flag here to “prod” fails with a class not found error, but works with “dev”, so I’m using that. If you give it a go and solve the problem, do let me know please.

然后,运行php app/console oro:install --env dev完全安装该应用程序,或在主机浏览器中访问http://test.app:8000 。 这将再花费10分钟左右,但这是最后一步。 由于某种原因,在此处将--env标志设置为“ prod”会失败,并出现未找到的类错误,但会与“ dev”一起使用,因此我正在使用它。 如果您可以解决问题,请告诉我。

You might have to activate the WebSockets server and the crontab, too, though these are optional:

您可能还必须激活WebSockets服务器和crontab,尽管这些是可选的:

php app/console clank:server --env prod
php app/console oro:cron --env prod

第6步:演示[可选] (Step 6: Demo [optional])

OroCRM comes with a set of demo data you can import into your instance so you have something to play around with. This is identical to what you can find on their demo page, but more flexible, as it allows you to alter the source code, extend the app, and properly play around in it.

OroCRM附带了一组演示数据,您可以将它们导入到实例中,以便您可以玩耍。 这与您在他们的演示页面上可以找到的相同,但是更加灵活,因为它允许您更改源代码,扩展应用程序并在其中正确玩转。

To install demo data, just run the following while inside the orocrm folder:

要安装演示数据,只需在orocrm文件夹中运行以下orocrm

php app/console oro:migration:data:load --fixtures-type=demo --env=prod
alt

结论 (Conclusion)

Was it too complicated? Perhaps. Then again, not many framework and app devs optimize their apps for VM installations just yet, so it’s no surprise. There’s not much the Oro team can do, anyway, seeing as they depend on some of the largest frameworks out there (Zend and Symfony both get installed during Composer Install, and in --prefer-sources mode the entire folder finally amounts to 420MB, which is ludicrous for a web app of any caliber; --prefer-dist wraps it up around 190MB).

太复杂了吗? 也许。 再说一次,还没有很多框架和应用程序开发人员针对VM安装优化其应用程序,因此不足为奇。 无论如何,Oro团队无能为力,因为它们依赖于一些最大的框架(Zend和Symfony都在Composer Install期间安装,并且在--prefer-sources模式下,整个文件夹最终达到420MB,这对于任何口径的Web应用程序来说都是荒谬的; --prefer-dist将其封装为190MB左右)。

I hope they’ll find ways to make the procedure lighter, or that they’ll at the very least focus on making version 2.0 much Vagrant-friendlier from the get-go and more multi-platform – especially since it’s now public knowledge that Symfony apps frequently have problems on Vagrant. Have you given this installation procedure a go yet? Let me know if you get stuck somewhere, and we’ll try and work through it together.

我希望他们能找到使程序更轻巧的方法,或者至少将重点放在使2.0版变得更加无所事事,并且具有更多的多平台性,尤其是因为现在众所周知,Symfony应用经常在Vagrant上出现问题。 您是否已经批准了此安装过程? 让我知道您是否被卡在某个地方,我们将尝试并共同努力。

翻译自: https://www.sitepoint.com/guide-install-orocrm-vagrant-box/

蛇呆在树上,整天无所事事

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值