Thursday 12 September 2013

Apache+MySQL+PHP in CentOS

Apache+MySQL+PHP

 -----------------------------------------------------------------------------------------------------------------------

http://dan.drydog.com/apache2php.html

Note: Download and install Additional YUM repositories,

-----------------------------------------------------------------------------------------------------------------------


 #mkdir  /software

#wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

#wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

#rpm -ivh epel-release-5-4.noarch.rpm

#rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm


 #yum install glibc glibc-common

#yum install gcc-*

#yum install zlib-*

#yum install openssl-*

#yum install libxml2-devel    (Require to compile PHP)

#yum install gdbm-devel     (GDM Library for PHP)



-----------------------------------------------------------------------------------------------------------------------

###### Install Mysql ######

-----------------------------------------------------------------------------------------------------------------------


 #cd /software


 Note:  If below mirror not working try another mirror for same version

#wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25-linux2.6-x86_64.tar.gz/from/http://mysql.mirror.kangaroot.net/


 #groupadd mysql

 

#useradd -g mysql mysql


 #tar -zxvf mysql-5.5.25-linux2.6-x86_64.tar.gz


 #cp -r  /software/mysql-5.5.25-linux2.6-x86_64   /opt/mysql


 #cd /opt/mysql/


 #chown -R mysql .


 #chgrp -R mysql .


 #scripts/mysql_install_db --user=mysql


 #chown -R root .


 #chown -R mysql data


 #cp support-files/my-medium.cnf /opt/mysql/my.cnf


 #chown root.mysql /opt/mysql/my.cnf


 #bin/mysqld_safe --user=mysql &


 #cp support-files/mysql.server /etc/init.d/mysqld


 #vi /etc/init.d/mysqld


 basedir=/opt/mysql


 #/etc/init.d/mysqld start


 #chkconfig mysql on


 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Note: If you have install mysql from tarball with some preffix,you need some changes after installing this package:

(Error 1: MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED])

(Error 2: Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/monitoring.example.com.pid).)


 #rm /var/lock/subsys/mysql

#mv  /etc/my.cnf /etc/my.cnf.backup

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


 #ln -s /opt/mysql/bin/mysql /usr/bin/mysql


 #cd /opt/mysql/


 #./bin/mysqladmin -u root password '******'


 #./bin/mysql -u root -p



mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;


 mysql> create database example;


 mysql> create user example IDENTIFIED BY 'example';


 mysql> GRANT ALL PRIVILEGES ON *.* TO 'example'@'%' IDENTIFIED BY 'example' WITH GRANT OPTION;


 mysql> GRANT ALL ON example.* TO 'example'@'localhost' IDENTIFIED BY 'example' WITH GRANT OPTION;


 mysql> quit


 Note: You can test the MySQL daemon with mysql-test-run.pl


 #cd ./mysql-test ; perl mysql-test-run.pl    (Optional step if you have lots of time to waste)


 #lsof -i :3306


 #iptables -I RH-Firewall-1-INPUT 1 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT


 #/etc/init.d/iptables save


 #/etc/init.d/iptables restart


 #rm -rf /software/mysql-5.5.25-linux2.6-x86_64



-----------------------------------------------------------------------------------------------------------------------

##### Install Aapache #####

-----------------------------------------------------------------------------------------------------------------------


 #wget  http://archive.apache.org/dist/httpd/httpd-2.2.21.tar.gz


 #tar -zxvf httpd-2.2.21.tar.gz


 #cd httpd-2.2.21


 #./configure --prefix=/opt/apache1 --enable-mods-shared=all --enable-so --enable-cgi --enable-proxy --enable-headers --enable-expires --enable-vhost-alias --enable-info --enable-rewrite --enable-speling    --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic


 #make


 #make install


 #vi /opt/apache1/conf/httpd.conf

Listen 80

User apache

Group apache

Include conf/extra/httpd-vhosts.conf


 #/opt/apache1/bin/apachectl -k restart


 #iptables -I RH-Firewall-1-INPUT 1 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT


 #/etc/init.d/iptables save


 #/etc/init.d/iptables restart


 #rm -rf /software/httpd-2.2.21


 -----------------------------------------------------------------------------------------------------------------------

### Install PHP ###

-----------------------------------------------------------------------------------------------------------------------

#yum install gd

#yum install libpng

#yum install libjpeg

#yum install php-gd

#yum install libpng-devel

#yum install libjpeg-devel

#yum install libXpm-devel

#yum install libmcrypt-*

#yum install uw-imap*    Note:  this package is available at  wget ftp://rpmfind.net/linux/epel/5/x86_64/uw-imap-2007e-14.el5.x86_64.rpm

#yum install libc-client

#yum install libc-client-devel



#cd /software


 #wget http://us3.php.net/get/php-5.4.0.tar.gz/from/in.php.net/mirror


 #tar -zxvf php-5.4.0.tar.gz


 #cd php-5.4.0


 Node: following configuration parameter would install gd extention support also.


 #./configure --prefix=/opt/apache1/php --with-apxs2=/opt/apache1/bin/apxs --enable-cli --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-config-file-path=/opt/apache1/php --with-mysql=/opt/mysql --with-xmlrpc --without-pear --with-gd --with-jpeg-dir=/opt/apache1/php --with-png-dir=/opt/apache1/php --with-mcrypt --with-mcrypt --with-zlib --with-gettext --with-gdbm  --enable-pdo  --with-pdo-mysql --with-imap --with-imap-ssl --with-kerberos  --with-openssl


 #make


 #make install


 #cp /software/php-5.4.0/php.ini-production /opt/apache1/php/php.ini


 #vi /opt/apache1/php/php.ini


 short_open_tag = On


 #vi /opt/apache1/conf/httpd.conf


 #++++++++PHP+++++++++++

# Make sure there's only **1** line for each of these 2 directives:

# Use for PHP 4.x:

#LoadModule php4_module modules/libphp4.so

#AddHandler php-script  .php

# Use for PHP 5.x:

#LoadModule php5_module  modules/libphp5.so

AddHandler php5-script  .php

# Add index.php to your DirectoryIndex line:

DirectoryIndex index.html index.php

AddType text/html    .php

# PHP Syntax Coloring

# (optional but useful for reading PHP source for debugging):

AddType application/x-httpd-php-source phps

#++++++++++PHP+++++++++++++++



#/opt/apache1/bin/apachectl -k restart


 #/opt/apache1/bin/httpd -M | grep php

Syntax OK

php5_module (shared)


 #rm -rf  /software/php-5.4.0

-----------------------------------------------------------------------------------------------------------------------

Note: This is the output of command make install during compilation (Read Carefuly)


 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[root@ticket php-5.4.0]# make install

Installing PHP SAPI module:    apache2handler

/opt/apache1/build/instdso.sh SH_LIBTOOL='/opt/apache1/build/libtool' libphp5.la /opt/apache1/modules

/opt/apache1/build/libtool --mode=install cp libphp5.la /opt/apache1/modules/

cp .libs/libphp5.so /opt/apache1/modules/libphp5.so

cp .libs/libphp5.lai /opt/apache1/modules/libphp5.la

libtool: install: warning: remember to run `libtool --finish /software/php-5.4.0/libs'

chmod 755 /opt/apache1/modules/libphp5.so

[activating module `php5' in /opt/apache1/conf/httpd.conf]

Installing PHP CLI binary:     /opt/php/bin/

Installing PHP CLI man page:   /opt/php/php/man/man1/

Installing PHP CGI binary:     /opt/php/bin/

Installing build environment:  /opt/php/lib/php/build/

Installing header files:       /opt/php/include/php/

Installing helper programs:    /opt/php/bin/

  program: phpize

  program: php-config

Installing man pages:          /opt/php/php/man/man1/

  page: phpize.1

  page: php-config.1

Installing PEAR environment:   /opt/php/lib/php/

[PEAR] Archive_Tar - installed: 1.3.7

[PEAR] Console_Getopt - installed: 1.3.0

[PEAR] Structures_Graph- installed: 1.0.4

[PEAR] XML_Util    - installed: 1.2.1

[PEAR] PEAR        - installed: 1.9.4

Wrote PEAR system config file at: /opt/php/etc/pear.conf

You may want to add: /opt/php/lib/php to your php.ini include_path

/software/php-5.4.0/build/shtool install -c ext/phar/phar.phar /opt/php/bin

ln -s -f /opt/php/bin/phar.phar /opt/php/bin/phar

Installing PDO headers:       /opt/php/include/php/ext/pdo/


 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-----------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment