bash: vagrant
This quick tip will show you how to install Phalcon on a Homestead Improved instance, and will help you get a sample Phalcon app up and running.
此快速提示将向您展示如何在Homestead Improvementd实例上安装Phalcon,并将帮助您启动并运行示例Phalcon应用程序。
The version of Phalcon we’ll be using in this Quick Tip will be 2.0 – a pre-release. If you read this when Phalcon is already in a mature 2.x stage, let us know and we’ll update the post. To install the stable 1.x version, just run sudo apt-get install php5-phalcon and it should work.
我们将在此“快速提示”中使用的Phalcon版本为2.0 –预发行版本。 如果您在Phalcon已经处于成熟的2.x阶段时阅读此书,请告诉我们,我们将更新该帖子。 要安装稳定的1.x版本,只需运行sudo apt-get install php5-phalcon 。
Get HI (Homestead Improved) up and running via this quick tip.
通过此快速技巧启动HI(改进的Homestead)并使其运行。
Add another site into the vhost configuration so your sites block looks like this:
将另一个站点添加到vhost配置中,以便您的站点被阻止,如下所示:
sites: - map: homestead.app to: /home/vagrant/Code/Laravel/public - map: test.app to: /home/vagrant/Code/phalcon_sample/publicZephir is the language that powers the new Phalcon. Instead of being written in C, Phalcon 2 is written in a mediator language called Zephir, designed solely for building PHP extensions. Find out more about it here.
Zephir是为新Phalcon提供动力的语言。 Phalcon 2不是用C编写,而是使用一种称为Zephir的中介语言编写的,该语言专门用于构建PHP扩展。 在此处了解更多信息。
sudo apt-get update sudo apt-get install gcc make re2c libpcre3-dev cd ~/Code git clone https://github.com/json-c/json-c.git cd json-c sh autogen.sh ./configure make && sudo make install git clone https://github.com/phalcon/zephir cd zephir ./install -cIf the VM is not up yet, run vagrant up, then enter the VM via vagrant ssh.
如果虚拟机尚未启动,请运行vagrant up ,然后通过vagrant ssh进入虚拟机。
cd ~/Code git clone http://github.com/phalcon/cphalcon cd cphalcon git checkout 2.0.0 zephir buildThis installs the extension. You still need to activate it by including it in your php.ini file.
这将安装扩展。 您仍然需要通过将其包含在php.ini文件中来激活它。
sudo su echo "extension=phalcon.so" >> /etc/php5/fpm/conf.d/20-phalcon.ini echo "extension=phalcon.so" >> /etc/php5/cli/conf.d/20-phalcon.ini exitLet’s check if it installed correctly. Restart nginx and php5-fpm. Run php -i | grep Phalcon. If you get any output at all (e.g. “Author => Phalcon Team”), the installation was a success.
让我们检查它是否正确安装。 重新启动nginx和php5-fpm。 运行php -i | grep Phalcon php -i | grep Phalcon 。 如果您没有得到任何输出(例如“ Author => Phalcon Team”),则说明安装成功。
We’ll use the Phalcon home page as a sample site.
我们将使用Phalcon主页作为示例站点。
cd ~/Code git clone https://github.com/phalcon/website phalcon_sampleOpen /app/var/config/config.php and change baseurl to / and debug to 1. BaseURL is misconfigured for an unknown reason, while debug needs to be activated to deactivate the caching component which is currently having problems working properly. This will be fixed in the future, so if you’re reading this any time after August 2014, try it out with the default settings.
打开/app/var/config/config.php和变化baseurl到/和debug到1 。 由于未知原因,BaseURL配置错误,同时需要激活调试以停用当前无法正常工作的缓存组件。 以后将修复此问题,因此,如果您在2014年8月之后的任何时间阅读此内容,请尝试使用默认设置。
The Nginx configuration of Phalcon is somewhat iffy, so some customization is required. Just replace the contents of /etc/nginx/sites-available/test.app (or x.app where x is the name of your virtual host defined in Homestead.yaml) with the following:
Phalcon的Nginx配置有些困难,因此需要一些自定义。 只需用以下内容替换/etc/nginx/sites-available/test.app (或x.app,其中x是Homestead.yaml中定义的虚拟主机的名称)的内容:
server { listen 80; server_name test.app; set $root_path '/home/vagrant/Code/phalcon_sample/public'; root $root_path; index index.php index.html index.htm; try_files $uri $uri/ @rewrite; location @rewrite { rewrite ^/(.*)$ /index.php?_url=/$1; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/test.app-error.log error; error_page 404 /index.php; sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root $root_path; } location ~ /\.ht { deny all; } }Save, exit, and restart Nginx with sudo service nginx restart.
使用sudo service nginx restart保存,退出并重新启动Nginx。
If you get a 502 error when you run the application after Step 5, there’s still an outstanding bug with Xdebug that’s preventing Phalcon 2 from working properly. It being under heavy development means it’ll be resolved shortly, but in the meanwhile, just going into /etc/php5/mods-available/xdebug.ini and commenting out the contents, then restarting with sudo service php5-fpm restartshould solve things for you.
如果在执行步骤5之后运行应用程序时遇到502错误,则Xdebug仍然存在一个突出的错误,该错误会阻止Phalcon 2正常工作。 它正在大量开发中,这意味着它会很快得到解决,但是与此同时,只需进入/etc/php5/mods-available/xdebug.ini并注释掉其中的内容,然后使用sudo service php5-fpm restart应该可以解决东西给你。
That’s it. You can now visit the site in your host’s browser by running http://test.app:8000 (or any other virtual host URL you defined, if you didn’t use test.app like I did above.
而已。 现在,您可以通过运行http://test.app:8000 (或您定义的任何其他虚拟主机URL,如果您没有像上面那样使用test.app ,在主机浏览器中访问该站点。
Feel free to start hacking away and experimenting on Zephir and Phalcon 2.0 code now!
立即开始破解并尝试Zephir和Phalcon 2.0代码!
翻译自: https://www.sitepoint.com/quick-tip-install-zephir-phalcon-2-vagrant/
bash: vagrant
相关资源:jdk-8u281-windows-x64.exe