Thursday, August 25, 2011

Coppermine Photo Gallery v1.5.14: Ubuntu Prep

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

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 valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword


3 Installing Apache2

Apache2 is available as an Ubuntu package, therefore we can install it like this:

aptitude install apache2

Now direct your browser to http://192.168.0.100, and you should see the Apache2 placeholder page (It works!):





Apache's default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.


4 Installing PHP5

We can install PHP5 and the Apache PHP5 module as follows:

aptitude install php5 libapache2-mod-php5

We must restart Apache afterwards:

/etc/init.d/apache2 restart


5 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 PHP file (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 the Apache 2.0 Handler, as shown in the Server API line.

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

6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It's a good idea to 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 Apache2:

/etc/init.d/apache2 restart

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

7 phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:

aptitude install phpmyadmin

You will see the following questions:Web server to reconfigure automatically:

- apache2

Configure database for phpmyadmin with dbconfig-common?

No Afterwards, you can access phpMyAdmin under http://192.168.0.100/phpmyadmin/:

Friday, August 19, 2011

Webmin : After Restart - connection refused

After install , the webmin running well but suddenly after restart the server , i got error said connection refused.

Before this i reinstall the webmin package but now i felt something wrong with webmin service. Then i try to restart the services but nothing happen but i got some message saying that no service webmin. Oooo walla .. i know the webmin service not started from beginning. So i used this command to restart webmin

sudo /etc/webmin start

That All , My webmin comeback nicely.

Thursday, August 11, 2011

Bagaimana nak create phpinfo.php

Kekadang susah ngak nak cari skrip phpinfo.php

SO disertakan untuk rujukan semua.

phpinfo();

?>

Friday, August 5, 2011

How to set up nginx with PHP 1.0.4 on Ubuntu

Continue from previous post : NGINX Installation

Step 1: Installation

$ sudo apt-get install php5-cgi

Step 2: Startup script for FastCGI

We want to create a Startup script for FastCGI PHP processes to run on every boot up. Here is the script I use:

!/bin/bash
BIND_DIR=/var/run/php-fastcgi
BIND="$BIND_DIR/php.sock"
USER=www-data
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
echo -n "Starting PHP FastCGI: "
mkdir $BIND_DIR
chown -R $USER $BIND_DIR
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
rm -rf $BIND_DIR
echo "$PHP_CGI_NAME."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL

Put the text above into /etc/init.d/fastcgi-php. Then run:
$ sudo chmod 755 /etc/init.d/fastcgi-php
$ sudo update-rc.d fastcgi-php defaults
$ sudo /etc/init.d/fastcgi-php start

Note the variables at the top of the script and adjust to fit your available RAM. The the php-cgi processes will get bigger after a while so allot at least 16-20MB for each. This script is slightly different than most I’ve found, in that it uses a UNIX socket instead of a TCP one for communication. UNIX sockets are faster, and you never have to worry about your firewall setup.

Step 3: Enable PHP processing

Create a new file /etc/nginx/fastcgi_php with this content:
# pass the PHP scripts to FastCGI server listening on UNIX socket
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fastcgi/php.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

Now define you virtual servers. You need to copy back the red colour text from this sample config to your default (make sure check your server path) :
server {
listen 80;
server_name example.com www.example.com;

access_log /var/log/nginx/example.com.access.log;

root /var/www/example.com;
index index.php index.html index.htm;
autoindex off;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
# Enable PHP
include /etc/nginx/fastcgi_php;

}

Notice the next to last line of the file. You can include this line in all of your server definitions to enable PHP processing through FastCGI.

Step 4: Enable the site:

Enable the site and reload the configs:

sudo /etc/init.d/nginx reload