Thứ Sáu, 28 tháng 9, 2012

How to Install Git on Ubuntu 12.04

About Git


Git is a distributed version control system released to the public in 2005. The program allows for non-linear development of projects, and can handle large amounts of data effectively by storing it on the local server. 

This tutorial will cover two ways to install Git.

How to Install Git with Apt-Get


Installing Git with apt-get is a quick and easy process. The program installs with one command:
sudo apt-get install git

After it finishes downloading, you will have Git installed and ready to use.

How to Install Git from Source


If you are eager to download the most recent version of Git, it is generally a good idea to install it from the source. 

Quickly run apt-get update to make sure that you download the most recent packages.
sudo apt-get update

Prior to installing Git itself, download all of the required dependancies:
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential

Once they are installed, you can download the latest version of Git from the google code page.
wget http://git-core.googlecode.com/files/git-1.7.12.rc2.tar.gz

After it downloads, untar the file and switch into that directory:
tar -zxf git-1.7.12.rc2.tar.gz
cd git-1.7.12.rc2

If you want to do a global install, install it once as yourself and once as root, using the sudo prefix:
make prefix=/usr/local all
sudo make prefix=/usr/local install

If you need to update Git in the future, you can use Git itself to do it.
git clone git://git.kernel.org/pub/scm/git/git.git

How to Setup Git


After Git is installed, whether from apt-get or from the source, you need to copy your username and email in the gitconfig file. You can access this file at ~/.gitconfig. 

Opening it following a fresh Git install would reveal a completely blank page:
sudo nano ~/.gitconfig

You can use the follow commands to add in the required information.
git config --global user.name "NewUser"
git config --global user.email newuser@example.com

You can see all of your settings with this command:
git config --list

If you avoid putting in your username and email, git will later attempt to fill it in for you, and you may end up with a message like this:
[master 0d9d21d] initial project version
 Committer: root 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

See More


This tutorial covered how to install Git on your server. Stay tuned for a second tutorial on Git Basics.

How to Install APC and Memcached on Ubuntu

In my previous post I covered the installation of nginx, PHP-FPM and MySQL on Ubuntu. In this post I will cover the installation of APC and Memcached onto the server. As before I kept to the use of of packages located on the official Ubuntu repository in order to keep upgrading and maintainance headaches to a minimum. Also before these are the step I took on an Ubuntu 12.04 LTS (Precise Pangolin) installation. However you should be able to follow the same steps with any older or newer release of Ubuntu.
Note that this post is meant as a follow up to my previous post on the installation of nginx, PHP-FPM and MySQL on Ubuntu which can be found here. However these steps should work fine for installing APC and Memcached in an Apache environment as well. Just be sure to replace the /etc/init.d/php-fpm restart commands with /etc/init.d/apache2 restart.
This post covers the installation of both APC and Memcached although you may not necessarily need both being that APC is generally capable of doing what Memcached does in smaller environments but depending on your websites software and infrastructure you may need Memcached in place of APC or in conjunction with APC.
First off I will cover the installation of APC which is as simple as running the following command.
sudo apt-get install php-apc
After the package has been installed you will need to restart the php-fpm process.
sudo /etc/init.d/php5-fpm restart
Once the php-fpm process has been restarted we can varify our APC setup by running the following command. You may need to install the PHP command line interface.
Install the PHP command line interface:
sudo apt-get install php5-cli
Command to check if APC has been installed correctly:
php -r "phpinfo();" | grep apc
you should receive output resembling the follow.
Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
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
<... clipped to save room ...>
That is that you now have APC installed on your server.
Next we move on to the installation of Memcached. As with APC the installation process is very simple and straight forward. First we will install the Memcached package.
sudo apt-get install memcached
After the Memcached package has been installed we will need to start the Memcached process.
sudo /etc/init.d/memcached start
After starting Memcached we will need to install the Memcache or Memcached PHP module. A simpleGoogle Search will help you learn the difrences between the two and help you decide on which best suits your needs.
Install php5-memcache:
sudo apt-get install php5-memcache
Or install php5-memcached
sudo apt-get install php5-memcached
Now restart your PHP-FPM process.
sudo /etc/init.d/php5-fpm restart
You now have both APC and Memcached installed and ready to be utilized to increase the performance of your server when dishing out your content. In my next post I will cover the setup and configuration of WordPress running on nginx  along with the plug in W3 Total Cache which will allow WordPress to fully utilize APC and/or Memcached to really liven up your blogs performance.
» Tags:  , 

Comments:4

  1. 11/12/11
    sudo apt-get install php5-memcache should be sudo apt-get install php5-memcached
    • JoeReply
      11/12/16
      I guess that would be a matter of choice either or will work. So it would be up to the person installing to make that choice on their own preferances. Simple overview of each package:
      memcached:
      PHP extension for interfacing with memcached via libmemcached library This extension uses libmemcached library to provide API for communicating with memcached servers.
      Newer Project.
      Newer Features.
      Faster.
      memcache:
      Memcached is a caching daemon designed especially for dynamic web applications to decrease database load by storing objects in memory. This extension allows you to work with memcached through handy OO and procedural interfaces.
      Mature Project.
      Binary not dependant on the libmemcached library.
      Support for more legacy code.
      I will add the optional php5-memcached line into the post as well so people will know they have the choice.
  2. 12/08/08
    nice article. I follow your step by step and so far no problem on Ubuntu 12.04 LTS
    btw, which is your recommendation? memcache or memcached?
    • 12/08/08
      Myself I generally use memcache the last server I set up however I went with memcached. Honestly I stuck to memcache simply to make sure things worked for older apps being memcached is fairly new on the scene compared to memcache.
      However I have read memcached being newer has a performance advantage over memcache. Honestly I have never done any benchmarks so I can not prove this one way or the other.
      I would suggest looking at these posts for a little more information between the two it seems to me at this time it’s basically up in the air if either has a true advantage over the other at this time unless the application being hosted takes advantage of the newer features contained in memcached.
      http://serverfault.com/questions/63383/memcache-vs-memcached
      http://stackoverflow.com/questions/1442411/using-memcache-vs-memcached-with-php

Thứ Năm, 27 tháng 9, 2012

How to install MemCache on Windows 7 X64 for PHP with WAMP


Basics

The memcache sonsists of 2 parts: the server MemCached and the client MemCache.
  • MemCached is the cache server, the same as Mysqld (mysql server), which save and feed cache to clients.
  • MemCache is a client. With php, we need to install it as a mod, just the same as pdo_mysql (php_pdo_mysql.dll on windows).

Install MemCached

  • Download memcached from http://code.jellycan.com/memcached/ (get the win32 binary version). Here we suppose you extract the memcached in d:\memcached\.
  • If you are on Sindows Vista/7, rightclick on memcached.exe and select Properties; click on the Compatibility tab. At the bottom you’ll see Privilege Level, check “Run this program as an administrator”.
  • Open the command line by Win + R (or Start -> All Programs -> Accessories -> Command Prompt), and then run: d:\memcached\memcached.exe -d install to install the service.
  • Still in the command line, run d:\memcached\memcached.exe -d start, or net start "memcached Server" to start the service.
  • Check whether the service is running. Open Windows Task Manager, go to Services tab, you should find status of “memcached server” is “Running”.

Install MemCache php module

Note

  • To change MemCached memory size (default is 64mb), go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached Server in your registry, find the ImagePath entry and change it to:
    “C:\memcached\memcached.exe” -d runservice -m 512
  • More details see: memcached -help