installing cherokee with php5 and mysql support on ubuntu 9.10

Upload: yahya-nursalim

Post on 30-May-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    1/12

    Installing Cherokee With PHP5 And

    MySQL Support On Ubuntu 9.10Cherokee is a very fast, flexible and easy to configure Web Server. It supports the

    widespread technologies nowadays: FastCGI, SCGI, PHP, CGI, TLS and SSL encryptedconnections, virtual hosts, authentication, on the fly encoding, load balancing, Apache

    compatible log files, and much more. This tutorial shows how you can install Cherokeeon an Ubuntu 9.10 server with PHP5 support (through FastCGI) and MySQL support.

    I do not issue any guarantee that this will work for you!

    1 Preliminary Note

    In this tutorial I use the hostname server1.example.com with the IP address192.168.0.100. These settings might differ for you, so you have to replace them whereappropriate.

    I'm running all the steps in this tutorial with root privileges, so make sure you're logged in

    as root:

    sudo su

    2 Installing MySQL 5

    First we install MySQL 5 like this:

    aptitude install mysql-server mysql-client

    You will be asked to provide a password for the MySQL root user - this password is validfor the user root@localhost as well as [email protected], so we don't have to

    specify a MySQL root password manually later on:

    New password for the MySQL "root" user:

  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    2/12

    aptitude install cherokee

    Now direct your browser to http://192.168.0.100, and you should see the Cherokee

    placeholder page:

    Cherokee can be configured through a web-based control panel which we can start asfollows:

    cherokee-admin -b

    (By default cherokee-admin binds only to 127.0.0.1 (localhost), which means you can

    only connect to it from the same system. With the -b parameter you can specify the

    network address to listen to. If no IP is provided, it will bind to all interfaces.)

    Output should be similar to this one:

    root@server1:~# cherokee-admin -b

    Login:User: adminOne-time Password: 0VNcEcyFrLS7gLW4

    Web Interface:URL: http://localhost:9090/

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/1.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/1.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    3/12

    Cherokee Web Server 0.99.19 (Aug 29 2009): Listening on port ALL:9090,TLSdisabled, IPv6 disabled, using epoll, 1024 fds system limit, max. 505

    connections, caching I/O, single thread

    You need the username and password to log into the web interface which can be found on

    http://192.168.0.100:9090/:

    This is how the web interface looks:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/2.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/2.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    4/12

    To stop cherokee-admin, type CTRL+C on the shell.

    4 Installing PHP5

    We can make PHP5 work in Cherokee through FastCGI. Fortunately, Ubuntu provides aFastCGI-enabled PHP5 package which we install like this:

    aptitude install php5-cgi

    5 Configuring PHP5

    We must modify /etc/php5/cgi/php.ini and add the line cgi.fix_pathinfo = 1 right at theend of the file:

    vi /etc/php5/cgi/php.ini

    [...]cgi.fix_pathinfo = 1

    Then we restart Cherokee:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/3.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/3.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    5/12

    /etc/init.d/cherokee restart

    6 Enabling PHP5 In Cherokee

    PHP is not enabled in Cherokee by default. To enable it, we need to start Cherokee's

    web-based control panel...

    cherokee-admin -b

    ... and log into it (http://192.168.0.100:9090/).

    Now go to Virtual Servers, pick the default vhost and go to the Behavior tab:

    Click on the Wizards button:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/4.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/4.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    6/12

  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    7/12

    PHP should now be listed on the Behavior tab. Make sure you mark its checkbox in theFinal column:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/6.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/6.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    8/12

    By clicking on the php link in the Target column, you can change the default PHPsettings if you like (this is not necessary, the default settings should be fine in most

    cases). The FastCGI settings are on the Handler tab:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/7.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/7.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    9/12

    Before you leave the control panel, make sure you restart Cherokee for the changes totake effect. To do so, select Graceful restart under Save Changes in the left column of the

    control panel and click on Save:

    Press CTRL+C on the command line to stop the control panel.

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/8.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/8.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    10/12

    7 Testing PHP5 / Getting Details About Your PHP5 Installation

    The document root of the default web site is /var/www. We will now create a small PHPfile (info.php) in that directory and call it in a browser. The file will display lots of useful

    details about our PHP installation, such as the installed PHP version.

    vi /var/www/info.php

    Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

    As you see, PHP5 is working, and it's working through FastCGI, as shown in the Server

    API line. If you scroll further down, you will see all modules that are already enabled inPHP5. MySQL is not listed there which means we don't have MySQL support in PHP5

    yet.

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/10.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/10.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    11/12

    8 Getting MySQL Support In PHP5

    To get MySQL support in PHP, we can install the php5-mysql package. It's a good ideato install some other PHP5 modules as well as you might need them for your

    applications. You can search for available PHP5 modules like this:

    aptitude search php5

    Pick the ones you need and install them like this:

    aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-

    recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

    Now restart Cherokee:

    /etc/init.d/cherokee restart

    Now reload http://192.168.0.100/info.php in your browser and scroll down to themodules section again. You should now find lots of new modules there, including the

    MySQL module:

    http://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/11.pnghttp://images.howtoforge.com/images/cherokee_php5_mysql_ubuntu_9.10/big/11.png
  • 8/9/2019 Installing Cherokee With PHP5 and MySQL Support on Ubuntu 9.10

    12/12

    9 Links

    Cherokee:http://www.cherokee-project.com/ PHP: http://www.php.net/ MySQL: http://www.mysql.com/ Ubuntu: http://www.ubuntu.com/

    http://www.mysql.com/http://www.mysql.com/http://www.ubuntu.com/http://www.ubuntu.com/http://www.ubuntu.com/http://www.ubuntu.com/http://www.ubuntu.com/http://www.mysql.com/http://www.php.net/http://www.cherokee-project.com/