Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • How to gracefully handle WordPress plugin activation errors?

    Posted on February 25th, 2012 phpguru No comments

    Things I learned while attempting to build a custom WordPress plugin…

    A) The documentation is far from clear.
    B) There’s lots of ways of doing it
    C) Many blog posts exist around the net with tutorials and examples, and many of them are outdated
    D) Proper, logical coding practices and assumptions do not work.
    E) You have to just mess with it until it works.

    I inherited a fairly large 15-domain WordPress multi-site which uses Ajax, inline dynamic CSS, and inline dynamic Javascript throughout the theme. Page load times without caching are anywhere from 7 to 15 seconds per page. I can’t have page load times this long, so I should use caching, I think to myself.

    “The world is already flooded with blog posts about how great W3 Total Cache is and how terrific Super Cache is and how fantastic Bat Cache is. Surely one of these will work for me,” I think to myself.

    But alas, I tested using each of these plugins on my site and none of them really did the trick. W3 Total Cache actually broke my theme completely and threw errors; Super Cache didn’t help much either. And Bat Cache was just complete rubbish. Discouraged, I decided to write my own plugin from scratch. So, off I go.

    I’ll write a custom caching plugin that uses Memcache.

    After a week of off-and-on development, I got my caching plugin working extremely well: What was up to 15 seconds is now sub 300ms! Same page, same WP Multi-site, one plugin with only about 300 lines of code. But it only works in a highly-controlled environment. I want to put it up on the WordPress site so others can use it, but before I can release it into the wild, I need to make sure it’s really polite about errors and easy to work with.

    Specifically, I have these 3 simple goals to finish it up:

    1) If you don’t have the Memcache extension installed when you try to activate the plugin, it needs to display a warning message about missing extension;

    2) I want to use the standard h2 error message to display this error to the user; and

    3) I want the plugin to remain deactivated if activation fails.

    You would think the WordPress Codex, Plugin Resources and Plugin API Documentation would be chock full of great examples for Plugin developers, wouldn’t you? I did, too, but unfortunately this just isn’t the case.

    I’ll give examples of A through E above, and hopefully explain how I was able to achieve the proper implementation points of 1, 2 and 3.

    How do you handle WordPress Plugin Activation errors gracefully?
    This post says to use the wp_die( ) function.

    I tried that and it actually does prevent the plugin from getting activated.

    This post suggests that you should just let the fatal error happen and display a slightly better error message in a status box. Terrible idea, IMO.

    Better to use this. Render red error messages in h2′s like this post shows. I’m trying to combine these concepts into a single, elegant solution and having a real rough time of it.

    I think the only way to do it is like HungryCoder says, you have to freaking ob_start and catch the error with output buffering…

     

  • Top 10 Redis Resources Online

    Posted on February 4th, 2012 phpguru 2 comments

    Chances are you’ve heard of Memcache. Tons of websites use it to speed up page load times. I often say that Redis is like Memcache on steroids. You may not have heard of Redis, but if you’re using Memcache or APC, you should see how Redis could improve what you’re already doing. If you’re not using Memcache or APC yet, don’t bother – I urge you to take a look at Redis for a bunch of reasons.

    First, Memcache is a key-value store only. You set a string value under a string key, and that’s it. With Redis, on the other hand, you have the luxury of several different types of data storage, including keys and values, but Redis also supports hashes, lists, sets and sorted sets.

    An example to help explain why this is such a huge improvement. Say you have a big array of data, such as the kind that can come back from a web service request, like a parsed XML file or JSON packet. With Memcache, to store this in memory you have to serialize the data, often base64 encode the data, and then store it on the way in, and then to get a portion of the data back out again, you have to get the whole string, base64 decode it, deserialize it and then you can read from it. These extra steps needlessly chew up compute cycles.

    With the same data object stored in a Redis Hash, for example, you can have instant access to the data stored in any key of the hash, you don’t have to grab the whole thing, deserialize it and all that mess. Just a single line of code, and boom, there’s your data. Much more elegant.

    Another key reason Redis is superior to Memcache is that when you ask Memcache to store something, it’s in memory and that’s it. If your server goes down and you have to reboot, you have to repopulate your Memcache data over again. If your app has gotten huge, and your cache is huge, this can not only take awhile but puts a huge strain on your database server during this so-called “cache warmup” period. Unlike Memcache, Redis actually stores a copy of its data to a file on disk in the background, so if you stop and start your Redis server, it reloads everything automatically. It does this mind-blowingly fast, too, like millions of keys in seconds.

    Finally, Redis supports master-slave configurations that you can use to build high-availability systems more easily. In the upcoming release (everyone is very eager for) Redis Cluster will support sharding out of the box!

    So, now that you want to dig in and start learning Redis, here are my…

    Top 10 Redis Resources Online

    1. Redis documentation: redis.io/commands
    2. Try Redis Online: try.redis-db.com
    3. Redis-DB Google Group List Archives: groups.google.com/group/redis-db
    4. Antirez (Redis developer Salvatore Sanfilippo’s) blog: antirez.com
    5. Recent blog posts about Redis: RSS Feed
    6. Q&A: stackoverflow.com/questions/tagged/redis
    7. The Little Redis Book – Just released openmymind.net/2012/1/23/The-Little-Redis-Book
    8. Slides from Redis Tutorial simonwillison.net/static/2010/redis-tutorial
    9. A Collection of Redis Use Cases www.paperplanes.de/2010/2/16/a_collection_of_redis_use_cases
    10. My GitHub Page. Chock full of Redis-related project forks. github.com/phpguru
    11. Bonus: Here’s a slideshow for a Redis 101 talk I gave if you’re interested.
    Notes
    You may be wondering about NoSQL and where Redis fits into this discussion. When people bring up NoSQL, I tend to think of MongoDB. Unlike Memcached and Redis, MongoDB is a general purpose document/object (think JSON) store that (strangely enough) allows you to use some SQL-like commands to retrieve subsets of your data. I think of Redis as a data structure server. You don’t use SQL to talk to Redis, so I guess it could be considered along with other NoSQL solutions. You can compare Redis to MongoDB by going to try.mongodb.org/

     

  • Configure Subversion with Apache and Security in 5 Easy Steps

    Posted on January 19th, 2012 phpguru No comments

    I’ve been running WampServer for years on my trusty Dell XPS running Windows XP Pro. A while back I installed Subversion and got it working with mod_dav and authz_svn to serve multiple repositories, each with their own user and group permissions. It was tricky to set up and there are some finer points that most documentation I read doesn’t address. I followed a few different web resources like this great beginners guide, but ultimately it boils down to the 5 simple steps below.

    Just recently I needed to add a new repository. I thought I had done everything right, but when I went to use it for the first time, I got the following errors:

    D:\svn\repos>svn mkdir http://localhost:8080/svn/myproject/trunk -m "Trunk"
    svn: OPTIONS of 'http://localhost:8080/svn/myproject': 200 OK (http://localhost:8080)
    D:\svn\repos>svn ls http://localhost:8080/svn/myproject/trunk
    svn: URL 'http://localhost:8080/svn/myproject/trunk' non-existent in that revision
    D:\svn\repos>svn ls http://localhost:8080/svn/myproject
    svn: Could not open the requested SVN filesystem

    If you are getting any of these common errors, this post is for you.

    When using svn over http, you have to use Apache’s configuration files to control access to each repository separately. Start by installing Apache, Subversion, and then referencing these three modules in your httpd.conf as follows:

    LoadModule  dav_module             modules/mod_dav.so
    LoadModule  dav_svn_module         modules/mod_dav_svn.so
    LoadModule  authz_svn_module       modules/mod_authz_svn.so

    Now we’re ready to begin.

    1) Add the repository:

    #> svnadmin create D:\svn\repos\myproject

    *(On Unix systems, chown -R myproject so it is writable by the user Apache runs as)*

    2) Edit your httpd.conf (or extras/httpd-vhosts.conf) adding something like this:

    <Location /svn/myproject>
       DAV svn
       SVNPath d:/svn/repos/myproject
       AuthType Basic
       AuthName "My Project SVN Repo"
       AuthUserFile c:/etc/svn-auth-file
       Require valid-user
       AuthzSVNAccessFile c:/etc/svn-acl
    </Location>

    3) Add the project to your svn auth file at c:/etc/svn-acl (it’s referenced in the Location directive in your Apache config.)

    [groups]
    yourgroupname = yourusername, user_b, user_c
    [myproject:/]   
    yourusername = rw
    @yourgroupname = rw

    This is what tells Apache which users and groups are allowed to access the path(s) in your repository.

    4) Give yourusername an htpasswd (and user_b and user_c)

    cd c:/etc/
    htpasswd -c svn-auth-file yourusername

    *(If that file already exists, omit the -c option)*

    5) Finally, restart Apache

    httpd -k restart

    Then you’re ready to create trunk

    #> svn mkdir http://localhost:8080/svn/myproject/trunk -m "Adding trunk"
    
    Committed revision 1.

    I got the errors shown above when forgetting step one or more of these steps.

     

  • Redis 101 at Desert Code Camp 2011

    Posted on October 27th, 2011 phpguru No comments

    I’m proud to announce that I’ll be teaching Redis 101 at Desert Code Camp on November 5, 2011.

    Redis is a powerful memory-resident data store.

    In order to give you a good background on what Redis is, let’s take a trip down memory lane, back to our first lesson on how computers work. Computers have a hard disk drive, which enables data and files to be stored permanently (or, at least, for very long periods of time). They also have memory, or RAM, which is volatile, but very, very fast, comparatively.

    Why do we need both hard-drives and memory? Economics, mainly. Cheap, huge hard drives can store millions of files permanently, even if the power goes out. The tradeoff to all that massive amount of permanent storage is that hard drives are slow. RAM, on the other hand, is volatile storage, meaning that whatever is in RAM is lost when you power down your computer. Data in RAM is blazing fast, though. The trade-offs for all that blazing speed are high cost and impermanence.

    The latest Solid State Disks (SSD’s) are breaking some of these rules by being decent-sized, permanent storage that’s faster and quieter than a regular hard drive, but not as expensive as RAM. SSDs are more like hard drives or memory sticks with no moving parts. What’s Cool About SSDs would make a good blog post in the near future.

    Back to caching. In general terms, a cache is simply a faster place to retrieve data from.

    Your computer can access data stored in RAM much, much faster than it can access files on disk. When you launch a program, your computer is reading the application data from disk (slow) and loading it into memory (fast) so you can work on it.

    Several forms of caching are used to speed up surfing the web.

    You’re probably most familiar with client-side caching—your browser cache, or Temporary Internet Files for you Windows users. Web browsers use a local cache (just a special hidden folder) on your hard drive to store the stuff you’ve downloaded before. The theory here is, if you’ve already downloaded the home page of a site, chances are most of the files, scripts and stylesheets are reused across other pages on the stite, so by keeping local copy in the cache, your browser doesn’t have to re-fetch assets from the server again.

    Server-side caching, on the other hand, is a technique implemented by web application architects, to help speed up web applications. Some of the things that can be cached on the server-side include frequently-used files, query results, or processing PHP templates into their rendered HTML. With server-side caching, the idea is to alleviate some or most of the work your web server has to do when processing a particular request.

    Going back to our lesson on how computers work, we know hard drives are slow and memory is very fast. So when talking about maximum performance for web servers, we had better be looking at storing data in memory.

    Two of the most popular memory-caching platforms for PHP are Memcache and APC, the Alternative PHP Cache. These PHP extensions have been around a very long time, and are able to utilize RAM, instead of files on disk, to make data available to your PHP scripts almost instantly.

    Memcache and APC are known as key-value stores. Memcache is only a key-value store, meaning that’s basically the only feature it offers. APC is a key-value store, and also an opcode cache. An opcode cache actually compiles PHP scripts into machine-executable code, very much like compiling C# into a .DLL or Java code into a .war file. Compiled code runs faster than code that has to be parsed first.

    With any key-value store, you hand it a key and some data, and then later, you can lookup the data again almost instantly by using the original key.

    So why Redis? Like Memcache, Redis is also a key-value store, but it also offers several unique, blazing-fast data structures, including hashes, sets, lists and more. In addition, Redis includes a terrific write-to-disk feature as well as master-slave replication, giving you an extremely flexible and powerful set of tools, that fits in perfectly with any database-driven web application. And all for the amazing low-low price of only $0.00! By combining APC’s opcode cache capabilities, with the flexibility of Redis, you have everything you need to make your web applications really scream.

    Whether you’ve never used a caching platform before or you’re already fluent in Memcache or APC for high-performance website scalability, come and learn why Redis is quite possibly the best thing since sliced bread.

  • Using XDebug with Command-line PHP and NetBeans

    Posted on October 25th, 2011 phpguru No comments

    Magic sauce, so easy to misplace:

    export $XDEBUG_CONFIG="idekey=netbeans-xdebug"
    echo $XDEBUG_CONFIG
    idekey=netbeans-xdebug

    The string, `netbeans-xdebug` is configurable inside NetBeans preferences.

  • How to install MySQL 5.5 on Mac OS X 10.7 Lion

    Posted on September 8th, 2011 phpguru 8 comments

    This may not be obvious, but on the new Macs that ship with Lion, you can use the MySQL 5.5 64-bit dmg installer. It works perfectly on Lion, even though the MySQL site (still, at the time of this writing) says Mac OS X 10.6 Snow Leopard. You can use the Preference Pane to stop and start MySQL.

    Now after MySQL 5.5 is running, strangely enough, you cannot simply launch terminal and type mysql -u rootBash will complain that it can’t find mysql. So we have to help it like so:

    1. Use your favorite text editor to edit the file /Users/%yourname%/.bash_profile If this file doesn’t exist you can create it.
    2. Add the following line to your .bash_profile export PATH=$PATH:/usr/local/mysql/bin and save the file. Be careful editing this file exactly as above. You can render terminal unable to find all your programs if you break your $PATH.
    3. Quit and relaunch terminal, or type source ~/.bash_profile and hit return to reload the changes in your profile.
    4. Check your $PATH by typing echo $PATH and pressing return. You should see something like this /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin
    5. Now you should be able to run mysql -u root which means there is no root password by default!
    6. Run this next, at the mysql prompt GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'your_password_here' WITH GRANT OPTION;This is how to secure your root user login.

    Now, for PHP to use this connection I had to tweak my system as shown below:

    1. Run phpinfo() and check out the path PHP is trying to use for mysql.sock. On my new Mac Mini, it was/var/mysql/mysql.sock
    2. From terminal, I did sudo find / -name mysql.sock -print
    3. The critical line of output shows that MySQL 5.5 installs the sock to /private/tmp/mysql.sock
    4. Now we need to create a symlink for PHP to be able to access the mysql.sock. Trouble is if you try it you’ll get an error because /var/mysql doesn’t exist. So next, do sudo mkdir /var/mysql
    5. Finally, do this sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

    Did that work for you?

  • Zend & RightScale: The Ferrari of PHP Deployment has Arrived

    Posted on August 15th, 2011 phpguru No comments

    Zend Server is already the Cadillac of PHP Application Servers.

    The Ferrari of PHP Application Deployments has arrived.

    At least some, if not many PHP application developers are comfortable maintaining an Apache-based web server on Linux, the critical hardware that most often drives the web. Apache is free, and PHP is free, but you can’t be afraid to roll up your sleeves and get your hands dirty if you need to upgrade your software, install a new module, or tweak your server config.

    Most, if not all PHP developers are familiar with Zend, the engine that powers the PHP scripting language interpreter, and many great sites are developed using the Zend Framework.

    Zend PHP Cloud Platform on RightScale

    The Zend Framework is an enormous collection of ready-to-go building blocks (object-oriented PHP classes) for building just about any type of web application. There’s no question that their Zend Studio IDE ($299, built on Eclipse) is a solid PHP development platform, and Zend Server ($1,195 and up for support licenses) provides a terrific web-based GUI for managing your development, staging or production server’s LAMP stack.

    A little pricey, maybe, but if you rely on a LAMP environment for your deployed software applications and you don’t have a lot of time or resources to be fiddling with your server software, Zend solutions still are excellent product choices to rely on from the company most closely associated with PHP development.

    In today’s inbox, Zend announced a partnership with RightScale. If you’re not already familiar with RightScale, their service piggy-backs onto Amazon AWS to give you a nice, clean, friendly UI to manage and deploy webscale applications in the cloud. If you’ve ever experimented with Amazon AWS, you know it can be a little confusing and cumbersome to manage multiple server configurations as they scale.

    "Considering PHP's ubiquity on the web, it wasn't a question of it embraced the cloud, but when," said Stephen O'Grady, Principal Analyst with RedMonk. "With the recently announced RightScale/Zend partnership, the two companies are offering PHP users the best of both worlds, with the time to market of Platform-as-a-Service (PaaS) and the flexibility of Infrastructure-as-a-Service (IaaS)."

    With RightScale, you can save server templates and security group configurations, manage users and more. In the same way that Jenkins can help you automate testing your PHP applications and delivering them seamlessly to your server environments, RightScale can help you manage multiple-server cloud server application architectures with ease. Really a big time-saver.

    Definitely not cheap, but absolutely worth checking out if you have a decent budget and need to save time managing PHP cloud deployments.

    Scalable, Flexible, Portable PHP in the Cloud

    RightScale and Zend recently introduced a solution to provide a best practices path to launching and maintaining highly-available PHP applications in the cloud. Learn more about the RightScale and Zend Solution Pack: attend our webinar on August 17.

    Join us on August 17 for a demo of this new cloud solution that
    enables you to:

     

    Provision a pre-configured, high availability PHP environment
    in minutes
    Autoscale your application based on system and application
    load metrics
    Receive system, server and application-level monitoring,
    alerting and diagnostics
    Abstract your application from underlying cloud infrastructure to
    enable future portability 

    Topic: Introducing “PaaS in a Box”: Scalable, Flexible, Portable PHP in the Cloud
    Date: Wednesday, August 17
    Time: 9 AM PT / 12 PM ET / 5 PM BST / 6 PM CEST
    Speakers: Uri Budnik – Director ISV Partner Program, RightScale
    Claudio Gentile – Sales Engineer, RightScale
    Kevin Schroeder – Zend Technology Evangelist, Zend

     

    Register


     

     

  • How to install PHP APC extension on Snow Leopard

    Posted on August 11th, 2011 phpguru No comments

    I followed several posts on the Apple Suppor forum to install APC on Snow Leopard (not Server, but this forum seems much more appropriate as I am using Snow Leopard on my local MBP 17 for serious web development, trying to match my Ubuntu Server config as closely as possible.)

    Most notably, these:

    discussions.apple.com/thread/2448001
    discussions.apple.com/message/12923918
    discussions.apple.com/message/11696363
    discussions.apple.com/message/10454666

    as well as

    www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/
    serverfault.com/questions/206633/failed-to-instal-apc-via-pecl-install-apc

    I had to instal PCRE 8.12 before APC 3.1.9 install would work. Wincent has perfect instructions for that.

    Now back in my APC source directory, doing phpize and ./configure resulted in test failures; I realized that the recommended way of installing APC is via pecl channel-discover pecl.php.net
    pecl install APC

    This succeeded: Build process completed successfully
    Installing '/usr/include/php/ext/apc/apc_serializer.h'
    Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so'
    install ok: channel://pecl.php.net/APC-3.1.9
    configuration option "php_ini" is not set to php.ini location
    You should add "extension=apc.so" to php.ini

    Okay, so I add extension=apc.so to php.ini and restart apache. sh-3.2# php -i | grep apc
    apc
    apc.cache_by_default => On => On
    apc.canonicalize => On => On
    apc.coredump_unmap => Off => Off
    apc.enable_cli => Off => Off
    apc.enabled => On => On
    apc.file_md5 => Off => Off
    apc.file_update_protection => 2 => 2
    apc.filters => no value => no value
    apc.gc_ttl => 3600 => 3600
    apc.include_once_override => Off => Off
    apc.lazy_classes => Off => Off
    apc.lazy_functions => Off => Off
    apc.max_file_size => 1M => 1M
    apc.mmap_file_mask => no value => no value
    apc.num_files_hint => 1000 => 1000
    apc.preload_path => no value => no value
    apc.report_autofilter => Off => Off
    apc.rfc1867 => Off => Off
    apc.rfc1867_freq => 0 => 0
    apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
    apc.rfc1867_prefix => upload_ => upload_
    apc.rfc1867_ttl => 3600 => 3600
    apc.serializer => default => default
    apc.shm_segments => 1 => 1
    apc.shm_size => 32M => 32M
    apc.slam_defense => On => On
    apc.stat => On => On
    apc.stat_ctime => Off => Off
    apc.ttl => 0 => 0
    apc.use_request_time => On => On
    apc.user_entries_hint => 4096 => 4096
    apc.user_ttl => 0 => 0
    apc.write_lock => On => On

    So now we know, from the command line anyway, PHP CLI is reporting it has APC installed.

    Now here’s the interesting part… from Apache (e.g. trying to run any local PHP file http://localhost/info.php for example) I just get a white page of death.

    If I comment that extension out and restart Apache, PHP files work again.

    Hmm, lets look at the error.tail -f error_log
    shows: Fatal error: Unknown: apc_fcntl_unlock failed: in Unknown on line 0

    I google that and find this bug report, where it is stated that a patch is available for apc_lock.h.

    I go back to the PECL APC source site and browse the sources in trunk, find the apc_lock.h file, download it, put it into my APC-3.1.9 source directory and run phpize
    ./configure
    make clean
    make install
    apachectl restart

    Note that `make clean` is the magic bit there since we already installed APC from these sources, we need to make a new fresh install from these same sources.

    Now everything is working happily again.

    Good luck with yours!

  • Kohana 3.x in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Prerequisites:

    This guide assumes you have already completed:

    So you have a LAMP/MAMP/XAMPP stack? Great!

    Now we’re ready to create our first Kohana project.

    1. Download the source from www.KohanaFramework.org
    2. Extract the zip file and move the directory it to your  web directory
      1. On Mac OS X: ~/Sites/* (subsequent references will use Mac notation)
      2. On Windows (wamp): C:/wamp/www/*
      3. On Linux (varies): /var/www/*
    3. Rename the directory to kohanasite.dev
      1. Remember the full path to this now
      2. something like /Users/yourname/Sites/kohanasite.dev
    4. Create an htdocs directory inside this directory
      1. Your hdtocs will be at the same level as Kohana folders application, modules and system.
      2. Remember the full path to this now
      3. something like /Users/yourname/Sites/kohanasite.dev/htdocs
    5. Drag index.php into the htdocs directory
    6. Edit 3 lines of index.php
      1. where it says $application = ‘application’; change it to $application = ‘../application’;
      2. where it says $modules = ‘modules’; change it to $modules = ‘../modules’;
      3. where it says $system = ‘system’; change it to $system = ‘../system’;
      4. save and close
    7. chmod or chown application/cache and application/logs to be writable by Apache
      1. open terminal, and cd to your application directory
        cd /Users/your-name/Sites/kohanasite.dev/htdocs
      2. chmod the two directories
        chmod 0777 cache && chmod 0777 cache
      3. or chown it to apache, wheel, www-data or whoever owns httpd process (ps aux | grep httpd)
    8. Create a VirtualHost entry in your Apache config.
      1. Depending on your install, this might be in httpd.conf or…
      2. on my Mac it’s at /private/etc/apache2/extra/httpd-vhosts.conf
      3. E.g.
        sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
        NameVirtualHost *:80
        <VirtualHost *:80>
        ServerName kohanasite.dev
        DocumentRoot "/Users/your-username-here/Sites/kohanasite.dev/htdocs"
        </VirtualHost>
      4. save and quit (type :wq and hit enter)
    9. Edit your hosts file to point to this site locally
      1. E.g.
        sudo vi /etc/hosts
        127.0.0.1   kohanasite.dev
      2. save and quit (:wq)
    10. Restart Apache
      1. sudo apachectl restart
    11. Move example.htaccess to htdocs and rename it to .htaccess
      1. Note, because it’s a “dot file” it will disappear on a Mac, so use terminal:
        mv ../example.htaccess .htaccess
    12. Now test your site at http://kohanasite.dev
      1. It should say Hello World!

    Congratulations! You now have Kohana 3.1 running locally.

    Finishing up…

    Let’s enable some of the modules that come with Kohana 3.x

    1. Open up application/bootstrap.php
    2. Scroll down to the modules section
    3. Enable the following modules by removing the double slash in front of the module name:
      1. auth
      2. cache
      3. codebench
      4. database
      5. orm
      6. userguide
    4. Save the bootstrap file and refresh your browser to make sure you still get hello world

     

    Next up… How to build a simple CMS using Kohana.

  • Apache, PHP and MySQL in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Whether you want to start developing web applications for the first time, you’re wanting to make better use of your local computer or a virtual machine to streamline development, create a development or staging server, or just checking back as a reference for a new platform, welcome to…

    Apache, PHP and MySQL in 10 Minutes

    In this guide you will find the resources needed to build a web development environment on the platform of your choice

    1. Choose Your Platform – Mac, Windows or Linux.
      1. Mac OS X Instructions
        1. Easy - Using MAMP
        2. Intermediate - Using built-in Apple Apache
      2. Windows Instructions
        1. Install WampServer
        2. Install XAMPP
      3. Linux Instructions
        1. Install LAMP stack on CentOS/RHEL
        2. Install LAMP stack on Debian/Ubuntu
        3. Install LAMP stack on Fedora
        4. Install LAMP stack on OpenSUSE
        5. Install LAMP stack on ArchLinux
      4. CPanel
        1. CPanel comes with Apache & PHP already installed, so here’s how to customize your install
        2. Note – make sure your config comes with WHM (Web Host Manager)
        3. Many ISPs call this a Reseller account
        4. How to use the EasyApache script
      5. Plesk
        1. Plesk comes with Apache & PHP already installed, so here’s how to customize your configuration
        2. Parallels Plesk Apache Configuration Guide
    2. Install any PHP Extensions you might need
      1. The one PHP extension that Kohana requires you that doesn’t come by default (See Kohana 3.1 in 5 minutes) is mcrypt:
      1. Pluging mcrypt into OS X
      2. Enabling mcrypt under WampServer
      3. Install mcrypt for php under Linux
      4. Install mcrypt under CPanel
    3. How to create a VirtualHost
      1. Find your Apache Config file
      2. Find your Apache VirtualHost config file
      3. Sample VirtualHost container
      4. <VirtualHost *:80>
        ServerName website.dev
        DocumentRoot "/Users/username/Sites/website.com"
        </VirtualHost>
      5. More from the Apache VirtualHost documentation
    4. How to edit your hosts file
      1. hosts file information
    5. Start Apache
      1. Start Apache
        1. Mac OS X:
          1. Terminal
            1. sudo apachectl start
          2. or start Web Sharing in System Preferences
        2. Windows
          1. WampServer – start all services using the taskbar tray icon
        3. Linux
          1. Debian/Ubuntu
            1. sudo /etc/init.d/apache2 [start | stop | restart ]
          2. Fedora
            1. service httpd [start | stop | restart]
          3. ArchLinux
            1. /etc/rc.d/httpd restart
          4. OpenSUSE
            1. apachectl [start | stop | restart]
    6. Test your install
      1. Go to http://localhost in your browser
      2. Are you seeing the Apache start page?
      3. If so, you are done. Congratulations! You just installed a web server.
    7. Install MySQL
      1. Mac OS X
        1. Installing MySQL on OS X
      2. Windows
        1. Installing MySQL on Windows
      3. Linux
        1. Installing from a binary
        2. Build MySQL 5.5 from source

     

    Now that you have a development environment, why not install a fantastic web development framework, such as Kohana.

    Ready for round two? Kohana 3.1 in 10 Minutes