What is MySQL?

What is MySQL?

What is MySQL?

If you are going to do some advanced stuff on your website, you will need to learn about MySQL. Knowledge on it is very important, especially if you are going to create websites that need to store data like usernames, passwords, comments, content, and many more. In addition, basic knowledge of this database is needed if you are going to proceed on learning advanced web development language like PHP. Moreover, it is a widely known and used database on the internet, lack of understanding of this database can give you a difficult time on progressing as a web developer. If you want to know the answer to “what is MySQL,” continue reading.

mysqlMySQL is the most famous open-source database system on the World Wide Web. MySQL is a relational database management system (RDBMS) that stores both data and the data’s relationships on the same table. Asides from that, a user can reassemble and access its data in many ways without the need of creating any changes to the tables. With MySQL, you can create up to 4,096 columns and store an almost unlimited number of records.

Just like any other databases, it can handle values like timestamps, dates, chars, floats, integers, and Boolean values. In addition, there are two ways that you can manipulate MySQL. You can use the regular SQL syntaxes like select, insert, update, join, show, and delete to edit tables. On the other hand, you can use a graphical administration application like the popular phpMyAdmin to manage your MySQL tables.

Even if you are going to rely on a content managing system (CMS) for the materialization of your website, you must still familiarize yourself on this database. This is generally because most of the popular CMS today, like WordPress and Joomla, are using this database as their data manager. In addition, common forum applications on the internet, like phpBB and MyBB, are using this database too. When your content management system or forum application goes down, you might want to recover all the data and content that application accumulated. If that happens, the only way to do that is to check its MySQL database manually.

Moreover, many webhosting services are using this as their database. This is especially true to those web servers that take advantage of the LAMP (Linux, Apache, MySQL, PHP/Phyton/Perl) software stack. That is why many popular websites are taking advantage of this database, and a few of them are Wikipedia, Google, YouTube, Twitter, Facebook, and Flickr. It can handle small to massive websites, and it can support huge volumes of users and data. Because of that, it is recommended that you use this in case that you will create a new website.

It is absolutely required to learn this database. If you are familiar with how databases work, learning MySQL will not be difficult for you. Whether you will manually code your website, or you will use content management applications for your websites, understanding this database will be beneficial for you. As of now, many learning sources on the internet can be found for you to start familiarizing yourself on this popular RDBMS.

{ 0 comments }

What Is PHP?

What Is PHP?

What Is PHP?

What is PHP? PHP or Hypertext Preprocessor is a popular and widely used server-side scripting language. It was originally made to create dynamic webpages, but because of its capabilities, it has found its way to be one of the best server-side scripting on the internet.

php-script2This language is capable of running scripts for a server, and it can carry out specific server tasks. Few of the common tasks it can perform are database manipulation and content management. The scripts will be saved on the server just like the web pages, and they will only be triggered when users request it to be executed.

In contrast to JavaScript, which is a client side scripting language, PHP codes are usually saved separately from a webpage, and its saved code will have an extension of ‘.php’. If the developer wants to integrate the code inside an HTML file or web page, he must make sure that he enclosed the code in PHP’s special start and end processing instructions, which are “<?php>” and “?>”. In addition, between the difference of PHP and JavaScript, PHP can generate contents of its own, and because of that, a single PHP file can produce thousands of pages, and the developer would not need to create files for those pages.

On the other hand, new users can instantly appreciate PHP because of its simplicity. However, they must familiarize themselves first on basic programming and JavaScript for them not to have difficulties on learning the language. Alternatively, experienced developers enjoy the numerous possibilities that can be achieved with PHP.

Many people are using this software because it is free. Moreover, this scripting can run on every virtually known operating system and platform, and it is compatible to many relational database management systems like MySQL.

In addition, its major competitors are Microsoft’s Active Server Pages (ASP), mod_perl, and Sun Microsystem’s JavaServer Pages. As of now, it is being used by numerous websites on the internet. A few renowned websites that use PHP are Facebook, Digg, and Wikipedia. On the other hand, many popular content management systems (CMS) today are written using PHP. A few of those CMS are WordPress, Joomla, MediaWiki and Drupal.

Alongside with PHP’s usefulness as a great server-side scripting language are its vulnerabilities. It has been reported that almost 30% of vulnerabilities recorded on the National Vulnerability Database are related to PHP. However, most of the vulnerabilities can be eliminated if developers follow best practice programming rules of PHP. In addition to that, programmers can apply advanced protection patches to enhance PHP’s security. On another note, a few of the vulnerabilities of PHP are denial-of-service (DoS), remote file inclusion, remote file execution, directory traversal, header injection, SQL injection, and cross-site scripting (XSS).

If you want to add more dynamics, interactivity, and functionality to your website, it is best for you to learn and implement PHP. It is easy to learn, as long that you already mastered the basics of web development and program writing. In addition, before you implement PHP, it is best for you to research on how to overcome PHP’s vulnerabilities.

{ 0 comments }

NginX: Load Balancing, Failover, and Geo Location (Part 3)

NginX: Load Balancing, Failover, and Geo Location (Part 3)

Okay we continue to the third part of this post title, on the previous part we use NginX as load balancer and failover, now we use NginX with Geo IP based to determine the best backend for the visitors to put, here is the illustration.

For instance, we have two backend servers located in UK and DE, then we put the visitors from United Kingdom to the UK backend, visitors from Germany to DE backend, and the rest will be divided into those two backend servers, let’s deal with it.

I assume you have installed NginX in your frontend and two backend servers, you can check the previous post for NginX installation. This GeoIP based location needs GeoIP database for the frontend server to determine where to put the visitor, so first we download and extract Lite version of GeoIP database from Maxmind with geo2nginx.pl script from http://markmaunder.com.

wget https://serversreview.net/pkgs/txt/geo2nginx.pl
chmod 755 geo2nginx.pl
wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
unzip GeoIPCountryCSV.zip
./geo2nginx.pl < GeoIPCountryWhois.csv > geo.conf
mv geo.conf /etc/nginx/

GeoIP database has been added to NginX directory, now to the configuration, here is the example of main configuration

(more…)

{ 0 comments }

Running PHP 5.2 and 5.3 On The Same Server

Running PHP 5.2 and 5.3 On The Same Server

Even though most of PHP applications is now running with PHP version 5.3, there are a few PHP applications are still running on PHP version 5.2, you can see what makes that thing happens here: http://php.net/manual/en/migration53.incompatible.php

So i guess it will be good for PHP programmer / developer to have PHP version 5.2 and 5.3 installed and running on the same machine (more economical than using two machines for each PHP version). So let’s get started.

Anyway i will use NginX as the webserver, so the main principle of two PHP version running on the same machine is CGI works using different localhost port.

Before installing PHP, we usually install webserver and database first, i assume that you all have installed NginX and MySQL, so i just skip to the PHP installation.

note: the configuration below is my usual config and dependencies, if you are experiencing error while configure or make php, try to find out about the missing dependencies by looking at this blog’s older posts or googling. The first four configuration of PHP will be the important note because we will separate PHP 5.3 and 5.2 configuration (php.ini) path.

--prefix=/usr/local53 --libdir=/usr/local53/lib --with-libdir=lib --with-config-file-path=/usr/local53/lib
--prefix=/usr/local52 --libdir=/usr/local52/lib --with-libdir=lib --with-config-file-path=/usr/local52/lib

Install PHP 5.3.8 with PHP-FPM

wget http://pkgs.serversreview.net/files/autoconf-2.13.tar.gz
tar -zxvf autoconf-2.13.tar.gz
cd autoconf-2.13
./configure
make && make install

wget http://pkgs.serversreview.net/files/php-5.3.8.tar.gz
tar -zxvf php-5.3.8.tar.gz
cd php-5.3.8
./buildconf --force
./configure --prefix=/usr/local53 --libdir=/usr/local53/lib --with-libdir=lib --with-config-file-path=/usr/local53/lib --enable-force-cgi-redirect --enable-fpm --enable-cli --with-mcrypt --enable-mbstring --with-openssl --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-zlib --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-png --with-jpeg --with-gmp --with-sqlite --enable-pdo --with-xpm-dir=/usr/lib --with-freetype-dir=/usr/include/freetype2 --with-ttf=/usr/include/freetype2 --enable-gd-native-ttf --enable-fileinfo --disable-debug --with-pic --with-bz2 --with-curl --with-curlwrappers --without-gdbm --with-gettext --with-iconv --with-pspell --with-pcre-regex --with-imap --with-imap-ssl=/usr/lib --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --disable-sysvsem --disable-sysvshm --disable-sysvmsg --enable-track-vars --enable-trans-sid --enable-yp --enable-wddx --with-kerberos --enable-ucd-snmp-hack --enable-memory-limit --enable-shmop --enable-calendar --enable-dbx --enable-dio --with-mime-magic --with-system-tzdata --with-odbc --enable-gd-jis-conv --enable-dom --disable-dba --enable-xmlreader --enable-xmlwriter --with-tidy  --with-xml --with-xmlrpc --with-xsl --enable-bcmath --enable-soap --enable-zip --enable-inline-optimization --with-mhash --enable-mbregex
make
make install

cp php.ini-production /usr/local53/lib/php.ini

(more…)

{ 0 comments }

Lighttpd, PHP with PHP-FPM, and MySQL Under Ubuntu Maverick

Lighttpd, PHP with PHP-FPM, and MySQL Under Ubuntu Maverick

It is time for Lighttpd the “Fly Light” webserver installation include PHP and MySQL under Ubuntu 10.10 Maverick, let’s go!

First, update repository list, install dependencies, and remove unneeded modules

apt-get update -y
apt-get install -y build-essential make automake patch cadaver bc netcat libgeoip1 libgeoip-dev fontconfig libfontconfig-dev libpam0g-dev libpam-devperm ldap-utils libldap-2.4-2 libldap2-dev libdb4.6 libxpm-dev libtool libaio-dev libltdl3-dev mcrypt libmcrypt-dev libmhash-dev unixodbc unixodbc-dev zip unzip nano perl openssl libssl-dev libdevel-repl-perl libperl-dev libpcre3 libpcre3-dev libjpeg62 libjpeg62-dev libpng-dev libtiff4 libtiff-dev libfreetype6 libfreetype6-dev libgmp3-dev aspell libaspell-dev libpspell-dev libiconv-ruby mlocate libc-client2007e libc-client2007e-dev uw-imapd tidy libtidy-dev libbz2-dev gamin libgamin-dev sqlite3 libsqlite3-dev libreadline6 libreadline6-dev e2fsprogs uuid-dev memcached libmemcache-dev
apt-get remove -y apache2 apache2-doc apache2-utils apache2.2-common bind9 php5 mysql-server curl libcurl3 libcurl-dev libidn11 libidn11-dev libxslt-dev

pkill apache2
pkill named
pkill sendmail-mta

Install additional modules

wget http://pkgs.serversreview.net/files/gd-2.0.33.tar.gz
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr --libdir=/usr/lib --with-png=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib --with-jpeg=/usr/lib --with-xpm=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libev-4.04.tar.gz
tar -zxvf libev-4.04.tar.gz
cd libev-4.04
./configure --prefix=/usr --libdir=/usr/lib --with-pic 
make
make install

wget http://pkgs.serversreview.net/files/gnupg-1.4.11.tar.gz
tar -zxvf gnupg-1.4.11.tar.gz
cd gnupg-1.4.11
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget libidn-1.9.tar.gz http://pkgs.serversreview.net/files/libidn-1.9.tar.gz
tar -zxvf libidn-1.9.tar.gz
cd libidn-1.9
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/curl-7.21.6.tar.gz
tar -zxvf curl-7.21.6.tar.gz
cd curl-7.21.6
./configure --prefix=/usr --libdir=/usr/lib --with-openssl --with-libidn  --enable-ipv6
make
make install

wget http://pkgs.serversreview.net/files/libxml2-2.7.8.tar.gz
tar -zxvf libxml2-2.7.8.tar.gz
cd libxml2-2.7.8
rm -rf /usr/lib/libxml2*
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libxslt-1.1.26.tar.gz
tar -zxvf libxslt-1.1.26.tar.gz
cd libxslt-1.1.26
rm -rf /usr/lib/libxslt* /usr/lib/libexslt*
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/lua-5.1.4.tar.gz
tar -zxvf lua-5.1.4.tar.gz
cd lua-5.1.4
sed -i 's/\/usr\/local/\/usr/g' Makefile
#if x86_64 then
#edit src/Makefile
#change CFLAGS= -O2 -Wall $(MYCFLAGS)
#with CFLAGS= -O2 -Wall -fPIC $(MYCFLAGS)
make linux install

wget http://pkgs.serversreview.net/files/valgrind-3.6.1.tar.bz2
tar -jxvf valgrind-3.6.1.tar.bz2
cd valgrind-3.6.1
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/libevent-2.0.11-stable.tar.gz
tar -zxvf libevent-2.0.11-stable.tar.gz
cd libevent-2.0.11-stable
./configure --prefix=/usr --libdir=/usr/lib
make
make install

wget http://pkgs.serversreview.net/files/gdbm-1.8.3.tar.gz
tar -zxvf gdbm-1.8.3.tar.gz
cd gdbm-1.8.3
./configure --prefix=/usr --libdir=/usr/lib
make
make install

(more…)

{ 0 comments }

Installing FFMPEG & FFMPEG-PHP from source

Installing FFMPEG & FFMPEG-PHP from source

This thing’s quite confusing me when i was trying to install FFMPEG and FFMPEG-PHP extension. You know it was always very easy if you’re install it from yum or rpm, but CentOS even EPEL doesn’t provide FFMPEG in their repository, so it is a bit bothering me if i had to use repository other than CentOS or EPEL, and that’s why i’m trying to install it from source. I was googling and found a lot of ‘how to’ about this, but they didn’t give a complete tutorial, also when there’s an error in dependency, i had to googling again until i found the solution. I had succeeded installing FFMPEG and FFMPEG-PHP extension both on 32bit / 64bit CentOS 5.6 and Ubuntu 10.10 Maverick, here’s the tutorial and the errors with solutions during the process of me installing FFMPEG.

I assume that your box is already installed with PHP, here as the example i’m using preinstalled NginX, MySQL, PHP from NginX Auto Installer without FFMPEG. First we’re going to install codecs and dependencies, after that FFMPEG and FFMPEG-PHP.

note:
Lib directory CentOS 32bit is /usr/lib
Lib directory CentOS 64bit is /usr/lib64
Lib directory Ubuntu 32bit and 64bit is /usr/lib64

YASM

wget http://pkgs.serversreview.net/files/yasm-1.1.0.tar.gz
tar -zxvf yasm-1.1.0.tar.gz
cd yasm-1.1.0
./configure --prefix=/usr --libdir=/usr/lib
make
make install

(more…)

{ 0 comments }

Ubuntu 10.04.2 Lucid With NginX – PHP – MySQL

Ubuntu 10.04.2 Lucid With NginX – PHP – MySQL

My friend told me about my NginX Auto Installer, too bad because it only support CentOS, he really want to use my auto installer if it supports Debian or Ubuntu. As i said before, i’ve never tried OS other than CentOS, so last night i tried to install NginX, PHP, and MySQL under Ubuntu 10.04.2 Lucid, guess what? It was confusing me, why can’t this OS just give a standard name for their modules and packages? For example, on CentOS if we want to install PAM and PAM devel, then we’re just type

yum install pam pam-devel

but on Ubuntu

apt-get install libpam0g-dev libpam-devperm

Why not creating the normal name like ‘pam’ for package name and ‘pam-devel’ for development package name? I had to do googling for almost of those packages which i wanted to install because they have a ‘not normal’ name. :p

Okay, enough with the preamble story, here’s the result of my experiment.

Box: Ubuntu 10.04.2 Lucid 64bit with 256MB RAM OpenVZ

First update Ubuntu repository list and update existing packages

apt-get update
apt-get upgrade

Install dependencies

apt-get install -y build-essential make automake patch bc netcat libgeoip1 libgeoip-dev fontconfig libfontconfig-dev libpam0g-dev libpam-devperm slapd ldap-utils libldap-2.4-2 libdb4.6 libxpm-dev libtool libaio-dev libltdl3-dev libmcrypt-dev libmhash-dev unixodbc unixodbc-dev zip unzip nano perl openssl libssl-dev libdevel-repl-perl libperl-dev libpcre3 libpcre3-dev libjpeg62 libjpeg62-dev libpng-dev libtiff4 libtiff-dev libfreetype6 libfreetype6-dev libgmp3-dev aspell libaspell-dev libpspell-dev libiconv-ruby mlocate libc-client2007e libc-client2007e-dev uw-imapd tidy libtidy-dev libbz2-dev libmysqlclient15-dev

Because i want to build NginX, PHP, and MySQL manually from source, also i will update a few dependencies for PHP, so now remove the following packages and also stop apache and bind processes.

apt-get remove apache2 php5 mysql-server gnupg curl libcurl3 libcurl-dev libidn11 libidn11-dev libxslt-dev
killall -9 apache2
killall -9 named

Install GD Library

wget http://pkgs.serversreview.net/files/gd-2.0.33.tar.gz
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr --libdir=/usr/lib --with-png=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib --with-jpeg=/usr/lib --with-xpm=/usr/lib
make
make install

(more…)

{ 0 comments }