Install Linux with Nginx, PHP5 (And PHP-FPM) And MySQL Support On CentOS (Part 2)

After doing the Part 1 article, now I continue installing and configuring other server softwares.

2. Install Nginx.

What is Nginx? Nginx (pronounced "engine x") is a free, open-source, high-performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption.

I already add the additional repo in Part 1 to install Nginx.
yum install nginx
then create start up link and start it
chkconfig --levels 235 nginx on
/etc/init.d/nginx start
make confirmation of Nginx installation by typing server IP address ( or hostname into my browser, and I got Nginx welcome page. Thats all for installing Nginx :)

3. Install PHP5

Nginx need PHP-FPM to work with PHP5. PHP-FPM (PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites). I install php-fpm together with php-cli and some PHP5 modules like php-mysql which I need to use MySQL from PHP.
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy
I also install APC, a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and Xcache. It is strongly recommended to have one of these installed to speed up PHP page.
yum install php-pecl-apc 
Open /etc/php.ini find and set cgi.fix_pathinfo=0:
I look in my system time zone and then set the same value in date.timezone in /etc/php.ini to avoid error in php error log.
cat /etc/sysconfig/clock
Create the system startup links for php-fpm and start it
chkconfig --levels 235 php-fpm on
/etc/init.d/php-fpm start
PHP-FPM is a daemon process (with the init script /etc/init.d/php-fpm) that runs a FastCGI server on port 9000

End of Part 2 


Install Linux with Nginx, PHP5 (And PHP-FPM) And MySQL Support On CentOS (Part 1)

I want to save my documentation on my web server installation, I use centos server and configure it with nginx, PHP5, php-fpm, and mysql.

First of all, I use the hostname server1.mylocal.com with the IP address

Now we begin.
First I need to enable additional repo because php-fpm is not available from the official CentOS repositories, but from the Remi RPM repository which itself depends on the EPEL repository; I enable both repositories as follows:
rpm --import https://fedoraproject.org/static/0608B895.txt
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install yum-priorities
Edit the /etc/yum.repos.d/epel.repo and add priority=10 to the epel section.
Edit the /etc/yum.repos.d/remi.repo, and add  priority=10 to the remi section, and change to enable=1

Now we're ready to install the softwares.

1. Install MySQL 5
yum install mysql mysql-server
first thing to do after installing a server software is to create a system startup link, so that MySQL starts automatically whenever the system boots.
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
check /etc/my.cnf and make sure the option skip-networking is commented out (not having # mark in front of the line), then restart mysql
/etc/init.d/mysqld restart
then run MySQL setup configuration to setup MySQL root password:

[root@server1 ~]# mysql_secure_installation


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
 <-- ENTER
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n]
 <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 <-- ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 <-- ENTER
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <-- ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 <-- ENTER
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

[root@server1 ~]#

End of part 1