{"id":76,"date":"2015-10-31T15:30:20","date_gmt":"2015-10-31T14:30:20","guid":{"rendered":"http:\/\/www.contentecontent.com\/blog\/?p=76"},"modified":"2015-11-04T13:26:07","modified_gmt":"2015-11-04T12:26:07","slug":"studio-without-server","status":"publish","type":"post","link":"https:\/\/www.contentecontent.com\/blog\/2015\/10\/studio-without-server\/","title":{"rendered":"Studio without Server"},"content":{"rendered":"<p>I&#8217;ve been using Zend Studio for many years now and think that it is a great IDE for building sites with PHP and JavaScript. IIRC I started with ZS 5; until this week I used version 9. I also ran a free Zend Server package, including Apache 2.2 and PHP 5.4. All this on an ordinary Windows 7 machine.<\/p>\n<p>As my production web server now runs on Apache 2.4 and PHP 5.6, an upgrade on the dev machine seemed appropriate. Also, Zend recently launched Studio 13, with support for PHP 5.6 and even PHP 7. I decided to upgrade everything at once.<\/p>\n<p><!--more--><\/p>\n<p>So I uninstalled the old Studio and Server, inluding the Apache\/PHP stack. Getting the new Studio and Server to run together was quite easy, and I worked with them for a couple of days without any problem. But then I decided to stop using Server. Why? Because of the toolbar.<\/p>\n<p>ZS 9 came with a Firefox toolbar that enabled launching PHP debug sessions from within the browser. Debugging scripts is perhaps the most important feature of an IDE, and starting a debug session should be as simple as possible. The toolbar enabled debugging the current page, posted forms and even XHR requests. Unfortunately Zend has decided drop it. It just won&#8217;t work with the Apache\/PHP stack that comes with Server.<\/p>\n<p>Server now comes with something called Z-Ray that provides all sorts of debugging information and also has a browser bar to launch a debugging session. However to me a license for Zend Server is way too expensive, so after the free trial expires I would not be able to debug from the browser. Exit Server.<\/p>\n<p>I now needed to get my own Apache\/PHP stack. There are plenty of packages out there, including WAMP packages that come with a single installer. But in order to make Studio communicate with PHP, another tool called Zend Studio Web Debugger is required. It can be downloaded <a href=\"http:\/\/www.zend.com\/en\/products\/studio\/downloads-studio#Windows\">here<\/a>.<\/p>\n<p>The readme file actually contained some very important information: <strong><code>Windows debuggers are built with VC11-NTS.<\/code><\/strong> It would have saved me quite some time had I read that before installing Apache and PHP. It means that the debugger will only run on a <em>non thread safe<\/em> version of Apache\/PHP, built with <em>VC11<\/em>.<\/p>\n<h2>Setup Apache and PHP<\/h2>\n<p>VC11 PHP 5.6 for Windows is available <a href=\"http:\/\/windows.php.net\/download\/\">here<\/a>. Pick the NTS version.<\/p>\n<p>VC11 compiled binaries of Apache can be downloaded at <a href=\"http:\/\/www.apachelounge.com\/download\/VC11\/\">ApacheLounge<\/a>.<\/p>\n<p>The NTS version of PHP can&#8217;t be used as an Apache module, so we&#8217;ll need some sort of (Fast)CGI implementation. I used mod_fcigd provided by <a href=\"http:\/\/www.apachelounge.com\/download\/VC11\/\">ApacheLounge<\/a>.<\/p>\n<p>I copied the Apache and PHP files to <code>C:\\webserver\\Apache24<\/code> and <code>C:\\webserver\\php56<\/code>, and put <code>mod_fcgid.so<\/code> in the <code>apache\\modules<\/code> folder.<\/p>\n<p>Now, edit <strong><code>httpd.conf<\/code><\/strong> (it&#8217;s in <code>Apache24\\conf\\<\/code>). First make sure that directives such as <code>DocumentRoot<\/code> match your path structure. In my case: <code>DocumentRoot \"c:\/webserver\/Apache24\/htdocs\"<\/code>. Also add <code>index.php<\/code> to <code>DirectoryIndex<\/code> :<\/p>\n<pre><code>&lt;IfModule dir_module&gt;\n     DirectoryIndex index.html index.php \n&lt;\/IfModule&gt;\n<\/code><\/pre>\n<p>Add these FCGI configuration lines somewhere at the end of httpd.conf:<\/p>\n<pre><code># first load the module\nLoadModule fcgid_module modules\/mod_fcgid.so\n\nFcgidInitialEnv PATH \"c:\/webserver\/php56;C:\/WINDOWS\/system32;C:\/WINDOWS;C:\/WINDOWS\/System32\/Wbem;\"\nFcgidInitialEnv SystemRoot \"C:\/Windows\"\nFcgidInitialEnv SystemDrive \"C:\"\nFcgidInitialEnv TEMP \"C:\/WINDOWS\/Temp\"\nFcgidInitialEnv TMP \"C:\/WINDOWS\/Temp\"\nFcgidInitialEnv windir \"C:\/WINDOWS\"\n# FcgidIOTimeout determines how long a PHP script can run before a timeout occurs. \n# Set it to something high; otherwise debug sessions will break. (value in seconds)\nFcgidIOTimeout 601\nFcgidConnectTimeout 16\nFcgidMaxRequestsPerProcess 1000 \nFcgidMaxProcesses 50 \nFcgidMaxRequestLen 8131072\n# Location of the folder with php.ini:\nFcgidInitialEnv PHPRC \"c:\/webserver\/php56\"\nFcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000\n\nAddHandler fcgid-script .php\nFcgidWrapper \"c:\/webserver\/php56\/php-cgi.exe\" .php\n<\/code><\/pre>\n<p>One very important setting in httpd.conf is the Options directive. We need to add <strong><code>ExecCGI<\/code><\/strong>; otherwise requests for .php files will throw an error 403 Forbidden.<\/p>\n<pre><code>&lt;Directory \"c:\/webserver\/Apache24\/htdocs\"&gt;\n    Options Indexes FollowSymLinks ExecCGI\n    ..\n&lt;\/Directory&gt;\n<\/code><\/pre>\n<p>My projects all live under C:\\projects, so I have a directory container with Options for them as well:<\/p>\n<pre><code>&lt;Directory \"c:\/projects\"&gt;\n    Options Indexes FollowSymLinks ExecCGI\n    AllowOverride All\n    Require all granted\n&lt;\/Directory&gt;\n<\/code><\/pre>\n<p><code>AllowOverride All<\/code> means that the Options directive can be overridden in .htaccess files. Make sure that you don&#8217;t break the ExecCGI option&#8230;<\/p>\n<p>Next, copy <code>php56\\php.ini-development<\/code> and rename it <strong><code>php.ini<\/code><\/strong>. Edit it:<\/p>\n<ul>\n<li>uncomment <code>extension_dir = \"ext\"<\/code><\/li>\n<li>uncomment the extensions you&#8217;ll be using, such as <code>php_mysqli.dll<\/code><\/li>\n<li>under [Date], put something like <code>date.timezone = Europe\/Amsterdam<\/code><\/li>\n<\/ul>\n<h2>Run Apache and PHP<\/h2>\n<p>Let&#8217;s see if things work. Launch a Windows Command Prompt window (click Start, type <code>cmd<\/code>, hit enter). Go to the Apache24\\bin directory and type <code>httpd<\/code>. It there are no error messages, Apache is running. Open <a href=\"http:\/\/localhost\/\">http:\/\/localhost\/<\/a> in your browser; there should be a page with &#8220;It works&#8221;.<\/p>\n<p>The Apache process can be stopped by pressing <code>Ctrl-C<\/code> in the command window. I noticed this may take a while.<\/p>\n<p>Try to run a PHP script too. For example, create a script called test.php in the Apache24\\htdocs directory, and put <code>&lt;?php phpinfo(); ?&gt;<\/code> in it. Open http:\/\/localhost\/test.php in the browser.<\/p>\n<h2>Adding the debugger and the toolbar<\/h2>\n<p>Copy <code>ZendDebugger.dll<\/code> to php56\\ext. Edit php.ini, add this:<\/p>\n<pre><code>[zendDebugger]\nzend_extension=ZendDebugger.dll\nzend_debugger.allow_hosts=127.0.0.0\/8,10.0.0.0\/8,192.168.0.0\/16,172.16.0.0\/12\nzend_debugger.expose_remotely=allowed_host\n<\/code><\/pre>\n<p>Restart the web server.<\/p>\n<p>Install the toolbar from the <a href=\"http:\/\/www.zend.com\/en\/products\/studio\/downloads-studio#Windows\">Studio download page<\/a>. It&#8217;s hidden under &#8220;Older versions&#8221;. Installation instructions are <a href=\"http:\/\/files.zend.com\/help\/Zend-Studio-10\/zend-studio.htm#installing_the_zend_debugger_toolbar.htm\">here<\/a>. In my Firefox toolbar settings I have manually set the Studio debug port to 10137 and IP address to 127.0.0.1.<\/p>\n<p><strike>From the zip file that contained ZendDebugger.dll, copy <code>dummy.php<\/code> into the web root of the site you want to debug.<\/strike> (Edit: it seems like this is not necessary.)<\/p>\n<p>You should now be able to launch a Studio debug session from the toolbar. Also, Zend Debugger should now be listed in <code>phpinfo()<\/code>&#8216;s output.<\/p>\n<h2>Apache service and monitor<\/h2>\n<p>In order to have Apache launched every time Windows is restarted, add it as a service. Launch the Command Prompt from the Start menu: right click the menu item and choose &#8220;Run as administrator&#8221;. Cd to Apache24\\bin and run <code>httpd -k install<\/code>.<\/p>\n<p>Apache comes with a handy tool that can monitor, stop and start the Apache service. Just double click on <code>ApacheMonitor.exe<\/code> in Apache&#8217;s bin folder, and it will from then on live in the notification area, bottom right of the Windows taskbar.<\/p>\n<h2>Final note<\/h2>\n<p><strike>This is probably not the fastest way to run Apache and PHP on Windows. In fact, I find it reacts rather slow to PHP requests. Please leave suggestions for improvements in the comments.<\/strike> (Edit: It had to do with MySQL and IPv6. Found solution <a href=\"http:\/\/stackoverflow.com\/questions\/11663860\/mysql-connect-localhost-127-0-0-1-slow-on-windows-platform\">here<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using Zend Studio for many years now and think that it is a great IDE for building sites with PHP and JavaScript. IIRC I started with ZS 5; until this week I used version 9. I also ran a free Zend Server package, including Apache 2.2 and PHP 5.4. All this on an &hellip; <a href=\"https:\/\/www.contentecontent.com\/blog\/2015\/10\/studio-without-server\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Studio without Server<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[7,14],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-misc","tag-php","tag-zend-studio"],"_links":{"self":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":13,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}