Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

4/03/2013

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 (192.168.0.121) 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:
 /etc/php.ini
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 

4/02/2013

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 192.168.0.121

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




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


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

11/23/2009

set chmod for folders only

Recursively chmod folders/directories only

find . -type d -exec chmod 755 {} \;

This will recursively search directory tree (starting at dir ‘dot’) and chmod 755 all directories only.

Similarly, the following will chmod all files only (and ignore the folders/directories):

find . -type f -exec chmod 644 {} \;

7/29/2008

Install eAccelerator on Centos 5.2

Still on pursuing to make a fast httpd server, I found eAccelerator at techiecorner.com. Here is what I gathered to install the eAccelerator on my Centos 5.2.

First lookup the latest PHP eAccelerator source distribution from here.
My downloaded version is eaccelerator-0.9.5.2.tar.bz2
Then:

$ tar -jxvf eaccelerator-0.9.5.2.tar.bz2
$ cd eaccelerator-0.9.5.2
$ phpize
$ ./configure
$ make
$ make install
after the last command, it shows this line:
Installing shared extensions: /usr/lib/php/modules/

Now we edit php.ini
$ nano /etc/php.ini
and add these line:

extension="eaccelerator.so"
eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”0″
eaccelerator.shm_prune_period=”0″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″

after saving the php.ini, I created temp folder for the eaccelerator

$ mkdir /tmp/eaccelerator
$ chmod 777 /tmp/eaccelerator

then restart the httpd:

$ httpd -k restart

to manage eAccelerator, I copied control.php
cp /usr/src/eaccelerator-0.9.5.2/control.php /path/to/my/homepage/control.php
when I tried to browse http://comp1/control.php, it asked for password, the default is :

Username : admin
Password : eAccelerator

but then I got "This script isn't in the allowed_admin_path setting" error in some area of the page. After took a peak on my ubuntu server configuration that already running eAccelerator, I added "eaccelerator.allowed_admin_path="/path/to/my/homepage"" so my php.ini now look like this :

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.allowed_admin_path="/path/to/my/homepage"


save the php.ini, then restart the httpd:

$ httpd -k restart

now I can login and manage the eAccelerator

Install PHP-MemCache On CentOS 5.2

I'm a linux newbie, but I want to speed up my webserver access, after googling around for days, I decided to try the php-memcache and I find most of my installation steps ini howtoforge.com. Here is what I did :

Install rpmforge repo
$ wget
http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-*.rpm
$ rpm --install rpmforge-release-*.rpm

Install memcached:
$ yum install --enablerepo=rpmforge memcached
test if memcached is running:
$ memcached -m 512 -u nobody -vv

start up the memcached daemon on as many spare machines as you have. The daemon has no configuration file, just a few command line options, only 3 or 4 of which you'll likely use:
$ ./memcached -d -m 2048 -l 10.0.0.40 -p 11211 -u nobody

This starts memcached up as a daemon, using 2GB of memory, and listening on IP 10.0.0.40, port 11211. The -m switch specifies the amount of memory in megabytes. The -l switch specifies the IP to listen on and finally the -p switch specifies the port to listen on. The default port is 11211 and if your machine has just 1 IP you can omit the -l parameter.

Install PHP MemCache extension
$ cd /usr/src/
$ wget http://pecl.php.net/get/memcache-2.2.3.tgz
$ tar -xvf memcache-2.2.3.tgzcd memcache-2.2.3
$ phpize && ./configure --enable-memcache && make
Copy the file memcache.so to the default module directory.
$ cp /usr/src/memcache-2.2.3/modules/memcache.so
/usr/lib/php/modules/memcache.so

Edit php.ini
$ nano /etc/php.ini
And add this line ini php.ini
extension=memcache.so
Restart Apache2
$ /etc/init.d/httpd restart
Now the php-memcache is installed

7/17/2008

Simple backup of MySQL

Sometimes I need to quick backup my database and download it to my pc, I use mysqldump command to do that and to save time of downloading, i compress it with gzip, here the command :

$ mysqldump -u MySQLuser -pMySQLpassword --opt db-name l gzip -c -9 > /path/to/backup/folder/backup-name.sql.gz

remember not to put spaces between -p and the password

and after i've download it, I create a db-name database in MySQL, and restore the backup using command :

$ gzip -d /path/to/backup/folder/backup-name.sql.gz
$ mysql -u MySQLuser -pMySQLpassword db-name < /path/to/backup/folder/backup-name.sql


remember not to put spaces between -p and the password !!