There are cases wherein we have to execute a command or a script say for daily basis for some maintenance purposes. In Linux there is a way that we could do it. It is through crontab (a cron job).
Assuming that we want to execute a command. Say we want to reset and resync our clock time with NTP server pool.
a.) Set up for scheduling command
The first thing to do is to locate the complete path of the command. So for our example let us locate where the complete path for ntpdate command is. Issue this command:
# whereis ntpdate
This will show you the different paths like this:
ntpdate: /usr/sbin/ntpdate /usr/share/man/man8/ntpdate.8.gz
Just take note of the bin or sbin path of the command. So in our case it is /usr/sbin/ntpdate.
b.) for scripts here's the set up
First create your script. If it is a shell script then on the first line of code you must have this. For other scripts like PHP just google out there and surely you will find many.
#!/bin/sh
Save your script. Set the file permission to 775 by issuing:
# chmod 775 (script)
Take note of the path where you saved the script we need this later on.
Next we'll open the crontab file by issuing this command.
# crontab -e
The flag 'e' signifies editing of the crontab file.
Once you're prompted on a file like this
~
~
~
~
"/tmp/crontab.XXXXtkRgpi" 7L, 546C
Press 'i' or insert key then you can start writing your schedules. When you are done. Just press escape key then press colon then 'w' and 'q' (:wq (a vi editor way of saving remember..)).
Before we proceed let me just discuss the format of the syntax that you will be enterring here.
* * * * * /complete/path/to/script/(command / filename of script to execute)
Example
*/1 * * * * /usr/sbin/ntpdate north-america.pool.ntp.org > /dev/null 2>&1
Let me explain...
the first * denotes minute (it can be from 0 - 59) minute
the second * denotes hour (military time 0 - 23) hour
the third is day of month (1 - 31)
4th is month (1 - 12)
5th the last one is day of week (0 - 6) 0 = Sunday
Say you want a schedule everyday at 12 midnight... here is an example
0 0 * * * /complete/path/to/script/(command / filename of script to execute)
If you want to execute per minute, here is how
*/1 * * * * /usr/sbin/ntpdate north-america.pool.ntp.org > /dev/null 2>&1
To list your current active cron jobs, issue:
# crontab -l
I hope you find these stuffs useful. Thanks, Cheers and God Bless!!!
You may not speak.... But the heart and mind from within say something...... It can't be hidden... it will eventually show itself from the dawn ...
Friday, February 6, 2009
Thursday, February 5, 2009
Fixed PHP compile error: Note that the MySQL client library is not bundled anymore!
Just a note that is worth be reminded for all CentOS version 5 users. One of the issues being encountered on compiling PHP with MySQL is the error:
Now how are you going to fix this?? Here's how.
On your configure command just locate or point the mysql lib base dir in my case it is on /usr
so just do ./configure --with-mysql=/usr
That will resolve your problem.
Hope this helps. Thanks, Cheers and God Bless!!
Note that the MySQL client library is not bundled anymore!
Now how are you going to fix this?? Here's how.
On your configure command just locate or point the mysql lib base dir in my case it is on /usr
so just do ./configure --with-mysql=/usr
That will resolve your problem.
Hope this helps. Thanks, Cheers and God Bless!!
Hardening PHP (Protecting your PHP from Flaws)
There are rumors going on out there that PHP has some pitfalls. This could lead up to some security risk most especially if you have a PHP application dealing with the outside world. To avoid this, some nice guys out there developed a 'guardian angel' for PHP. The guardian angel I am referring into is the suhosin. Yes suhosin is a korean word which mean 'guardian angel'. It is a PHP extension the secures PHP from its pitfalls or vulnerability.
I will discuss here on how to have this cool stuff on your PHP settings.
1. First download the suhosin signature key. Goto /usr/src then issue this command
# wget http://www.hardened-php.net/hardened-php-signature-key.asc
2. Import it into the GNU Privacy Guard
# gpg --import < hardened-php-signature-key.asc
3. Download the suhosin source
# wget http://download.suhosin.org/suhosin-0.9.27.tgz
4. Unpack the package
# tar xvzf suhosin-0.9.27.tgz
5. cd suhosin-0.9.27
6. After getting into the suhosin directory, issue the following
# phpize
# ./configure
# make
# make install
7. The library suhosin.so is most likely installed on /usr/src/suhosin-0.9.27/modules or it can be on /usr/local/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so
8. copy the suhosin.so to /usr/local/lib/php/extensions that is if you have installed php from source. Check other resources if you did not.
# cp /usr/src/suhosin-0.9.27/modules/suhosin.so /usr/local/lib/php/extensions
9. Open the php.ini
# vi /usr/local/lib/php.ini
10. Set the following parameters on php.ini
extension_dir = "/usr/local/lib/php/extensions/"
extension=suhosin.so
11. save it then restart apache
12. You should now see the suhosin among the enabled extension on your PHP. Check on the phpinfo for this.
Hope you find these info useful. Cheers, Thanks and God Bless!!!!
I will discuss here on how to have this cool stuff on your PHP settings.
1. First download the suhosin signature key. Goto /usr/src then issue this command
# wget http://www.hardened-php.net/hardened-php-signature-key.asc
2. Import it into the GNU Privacy Guard
# gpg --import < hardened-php-signature-key.asc
3. Download the suhosin source
# wget http://download.suhosin.org/suhosin-0.9.27.tgz
4. Unpack the package
# tar xvzf suhosin-0.9.27.tgz
5. cd suhosin-0.9.27
6. After getting into the suhosin directory, issue the following
# phpize
# ./configure
# make
# make install
7. The library suhosin.so is most likely installed on /usr/src/suhosin-0.9.27/modules or it can be on /usr/local/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so
8. copy the suhosin.so to /usr/local/lib/php/extensions that is if you have installed php from source. Check other resources if you did not.
# cp /usr/src/suhosin-0.9.27/modules/suhosin.so /usr/local/lib/php/extensions
9. Open the php.ini
# vi /usr/local/lib/php.ini
10. Set the following parameters on php.ini
extension_dir = "/usr/local/lib/php/extensions/"
extension=suhosin.so
11. save it then restart apache
12. You should now see the suhosin among the enabled extension on your PHP. Check on the phpinfo for this.
Hope you find these info useful. Cheers, Thanks and God Bless!!!!
Tuesday, February 3, 2009
Smart Host: Relaying Mails from Sendmail to Gmail
There are cases wherein the mails that are being sent from server does not arrive at the recipient's inbox. One possible cause is that the mail was considered a spam. One solution that can be done, dealing with this issue, is to relay the emails to a trusted SMTP host say like Gmail. How are we going to do it here is how.
First you need to have sendmail a native MTA for Linux. Here are the packages you need to have
- sendmail
- senmail-cf
- sendmail-devel
All of these packages can be installed via yum.
Next enable the smart host feature on sendmail. Open the sendmail configuration file.
vi /etc/mail/sendmail.mc
Change this:
dnl define(`SMART_HOST',`smtp.gmail.com')dnl
to:
define(`SMART_HOST',`smtp.gmail.com')dnl
Next add this entry before the entry of smart host.
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
If you don't have an /etc/mail/auth directory, as root, create one like this:
# mkdir -p /etc/mail/auth
# chmod 700 /etc/mail/auth
You won't have the next client-info files so you'll have to create it (with you favorite Unix editor). Change the permissions on the client-info file like this:
# chmod 600 client-info
So using my user_id@gmail.com email ID and password I made the following entry in /etc/mail/auth/client-info:
# cat /etc/mail/auth/client-info
AuthInfo:smtp.gmail.com "U:smmsp" "I:user_id" "P:password" "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:smmsp" "I:user_id" "P:password" "M:PLAIN"
Yes, password is plain text. It is possible to encode the password but I don't have those instructions here.
Remember to replace user_id with your Gmail email ID (your email addresse without the @gmail.com) and password with your email password. Also make sure that the client-info file has a
How to compile it into a db file:
# cd /etc/mail/auth
# makemap -r hash client-info.db <> sendmail.cf
And lastly restart sendmail:
# /sbin/service sendmail restart
Now you can test it....
Hope you find this useful. Thanks, Cheers and God Bless!!!!
First you need to have sendmail a native MTA for Linux. Here are the packages you need to have
- sendmail
- senmail-cf
- sendmail-devel
All of these packages can be installed via yum.
Next enable the smart host feature on sendmail. Open the sendmail configuration file.
vi /etc/mail/sendmail.mc
Change this:
dnl define(`SMART_HOST',`smtp.gmail.com')dnl
to:
define(`SMART_HOST',`smtp.gmail.com')dnl
Next add this entry before the entry of smart host.
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
If you don't have an /etc/mail/auth directory, as root, create one like this:
# mkdir -p /etc/mail/auth
# chmod 700 /etc/mail/auth
You won't have the next client-info files so you'll have to create it (with you favorite Unix editor). Change the permissions on the client-info file like this:
# chmod 600 client-info
So using my user_id@gmail.com email ID and password I made the following entry in /etc/mail/auth/client-info:
# cat /etc/mail/auth/client-info
AuthInfo:smtp.gmail.com "U:smmsp" "I:user_id" "P:password" "M:PLAIN"
AuthInfo:smtp.gmail.com:587 "U:smmsp" "I:user_id" "P:password" "M:PLAIN"
Yes, password is plain text. It is possible to encode the password but I don't have those instructions here.
Remember to replace user_id with your Gmail email ID (your email addresse without the @gmail.com) and password with your email password. Also make sure that the client-info file has a
How to compile it into a db file:
# cd /etc/mail/auth
# makemap -r hash client-info.db <> sendmail.cf
And lastly restart sendmail:
# /sbin/service sendmail restart
Now you can test it....
Hope you find this useful. Thanks, Cheers and God Bless!!!!
Monday, February 2, 2009
Some Linux Network Configurations and Files
I just wanted to list some of the common files or configurations in Linux for networking.
NETWORK Stuff
1.) /etc/sysconfig/network
-this one contains the hostname configuration of the machine so if you want to change the machine hostname do it here
- Sometimes the GATEWAY is configured here
2.) /etc/sysconfig/network-scripts/ifcfg-eth#
Ex. ifcfg-eth0 means eth0 , ifcfg-eth1 means eth1 or ethernet 1 or NIC 1
- the Network / LAN configuration of the machine where its IP is configured
- ifcfg-eth0:0 when there is a colon it means it is a virtual ethernet
3.) /etc/hosts
-local base bind or name service to resolve hostname
4.) /etc/resolv.conf
- DNS settings of the local machine
NETWORK Stuff
1.) /etc/sysconfig/network
-this one contains the hostname configuration of the machine so if you want to change the machine hostname do it here
- Sometimes the GATEWAY is configured here
2.) /etc/sysconfig/network-scripts/ifcfg-eth#
Ex. ifcfg-eth0 means eth0 , ifcfg-eth1 means eth1 or ethernet 1 or NIC 1
- the Network / LAN configuration of the machine where its IP is configured
- ifcfg-eth0:0 when there is a colon it means it is a virtual ethernet
3.) /etc/hosts
-local base bind or name service to resolve hostname
4.) /etc/resolv.conf
- DNS settings of the local machine
Thursday, January 29, 2009
Fixing Error "cannot open shared object file: No such file or directory"
There are instances during our installation that a shared object, commonly on .so files, cannot be openned or located. To fix this issue here are the steps to take.
1. locate the .so or object file that cannot be opened
locate (objectname).so
Ex. locate libmp4.so
-you will get the path
/usr/local/lib/libmp4.so.0
2. Take note of its path
3. Open ld.so.conf, usually it is on /etc/ld.so.conf
vi /etc/ld.so.conf
4. Add at the end the path of the shared object
include ld.so.conf.d/*.conf
/usr/local/lib/
5. Save it then issue this command
/sbin/ldconfig
-- You're done
Hope you find this helpful. Thanks and God Bless!!!
1. locate the .so or object file that cannot be opened
locate (objectname).so
Ex. locate libmp4.so
-you will get the path
/usr/local/lib/libmp4.so.0
2. Take note of its path
3. Open ld.so.conf, usually it is on /etc/ld.so.conf
vi /etc/ld.so.conf
4. Add at the end the path of the shared object
include ld.so.conf.d/*.conf
/usr/local/lib/
5. Save it then issue this command
/sbin/ldconfig
-- You're done
Hope you find this helpful. Thanks and God Bless!!!
Setting up a LAMP Server
It is a common task for Linux System Administrators to set up and to establish a web server. On Linux Systems it is common to have Linux, Apache, MySQL and PHP for production. In this tutorial I'll show you on how to set up LAMP with the latest Httpd (Apache), MySQL, and PHP. Here I'll be using CentOS 4.7.
Actually you can have a LAMP running Apache 2.0, PHP 5.1 and MySQL 5.0 on CentOS 4/RH4 easily with yum. How?
Here it is:
To install apache 2.0
yum --enablerepo=centosplus install httpd
To install mysql 5.1
yum --enablerepo=centosplus install mysql mysql-server
To install PHP 5.1
yum --enablerepo=centosplus install php
Then you are done you have a CentOS 4.x running Apache 2.0 MySQL 5.1 and PHP 5.1. Hmmm quite nice isn't it.
But how about if you really insist to have the latest. Well then here is how.
Of course you have to remove all the old Apache, PHP and MySQL instances. Here's how to do it.
1. First check if they are currently installed
rpm -qa|grep httpd ;to check if Apache is installed
rpm -qa|grep mysql ; to check if mysql is installed
rpm -qa|grep php ; to check if php is installed
2. If they are installed then remove them
yum remove httpd
yum remove mysql
yum remove php
3. Remove the remaining traces or dependencies of it
rpm -qa|grep php
you will see here like
php-common
php-pdo
remove them via
rpm -e php-common php-pdo
do the same thing on httpd and mysql
rpm -qa|grep (packagename)
then remove remaining traces
rpm -e (packagename)
4. Once all is clean we can start downloading all the latest packages for our new LAMP
Installing Apache
1. Goto /usr/src
cd /usr/src
1. Get the latest apache server say 2.2.x
wget http://apache.mirrors.biblionix.com/httpd/httpd-2.2.11.tar.gz
2. Extract it
tar xvzf httpd-2.2.11.tar.gz
3. cd httpd-2.2.11
4. then under the httpd folder do the following
./configure
make
make install
By default the apache is installed at /usr/local/apache2 folder
5. Set the necessary configuration you want for your web server
vi /usr/local/apache2/conf/httpd.conf
in my case I set my document root on /var/www/html
to avoid directoy listing do this
On directory directive you will see this
Options Indexes FollowSymLinks
make it like this
Options -Indexes FollowSymLinks
well enough on httpd configurations we'll have more on our next discussions to follow
6. To make the httd start at boot, we'll put it on Linux services. How?
- copy first the apachectl script from the httpd folder
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
- we put it on under init.d since all start up scripts are under this folder and being executed upon boot
- we're not done yet. Open httpd startup script.
vi /etc/init.d/httpd
- Add the following entries after the second line
# chkconfig: - 85 15
# description: Apache Web server
- let us add it on the Linux services
/sbin/chkconfig --add httpd
- then set it to start on running levels 345
/sbin/chkconfig --level 345 httpd on
- check if it is set well
/sbin/chkconfig --list|grep httpd
- you should see this
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
7. Now start the httpd service by
/sbin/service httpd start
8. to check if it is running
/sbin/service httpd status (only works for apache installed via rpm or yum)
or do
ps aux|grep httpd (works for all so just do this in our case)
- you should see either of the following
root 27093 0.0 0.1 4108 1808 ? Ss 14:31 0:00 /usr/local/apache2/bin/httpd -k start
apache 27114 0.0 0.1 4108 1640 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27115 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27116 0.0 0.1 4120 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27117 0.0 0.1 4108 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27118 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27119 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
-- now you have a running Apache server version 2.2
Installing MySQL
We'll do the RPM way of installing this one.
1. First you have to know what version of CentOS you have and what platform are you working in with.
- to know what platform are you working with issue the command
uname -i ; this will display or echo the platfrom in my case its i386
- to know what OS version are you running with open this file or just do cat
cat /etc/redhat-release ; this will display the OS version in my case it's CentOS release 4.7 (Final)
2. Since we're running i386 platform and version 4.x CentOS we'll download the necessary MySQL rpm packages suitable to this platfrom. In this case it is x86 or Red Hat Enterprise Linux 4 RPM (x86) downloads. Here are the things we need.
- MySQL-server-community-5.1.30-0.rhel4.i386.rpm
- MySQL-client-community-5.1.30-0.rhel4.i386.rpm
- MySQL-devel-community-5.1.30-0.rhel4.i386.rpm
- MySQL-shared-community-5.1.30-0.rhel4.i386.rpm
- so let's download them
wget http://(Mirror-linkname)/(rpmpackagename)
3. Once all neede packages are downloaded we can now install them. Issue the following command
- to install each of the packages issue this
rpm -ivh (packagename)
Ex. rpm -ivh MySQL-server-community-5.1.30-0.rhel4.i386.rpm
4. Then ensure that mysql service can start at boot.
/sbin/chkconfig --list|grep mysql
- you should see this
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- if it is not then make sure it runs / start on run level 345
/sbin/chkconfig --level 345 mysql on
5. Start MySQL service
/sbin/service mysql start
6. By default MySQL root has no password so just set its password say by installing first phpMyAdmin then reset password there or just go using the mysqladmin or mysql console command to reset password.
-- Now you have a running MySQL server version 5.1.x
Installation of PHP
Before we proceed on installing PHP we need the following to be installed first. These packages are known and commonly used on web development such as XML, web service and others
- curl (compile from source or you can do yum)
- curl-devel (if you did yum on curl)
- zlib (compile from source or do yum)
- libxml2 (compile from source or do yum)
- libxml2-devel (if you did yum on libxml2)
- openssl (you can do yum on this one)
- libpng (do yum here)
- libpng-devel (do yum here)
- gd (do yum)
- gd-devel (do yum)
Once all of these package are installed we can proceed on php installation.
1. Get the latest PHP packages from php.net
2. Goto /usr/src
3. Extract it there
4. cd php-5.x/
5. then issue this
./configure --with-mysql --enable-soap --with-apxs2=/usr/local/apache2/bin/apxs --enable-ftp --with-curl --with-curlwrappers --with-zlib --with-gettext --with-gd
make
make install
6. You now have installed PHP 5.x
7. There are things to verify to make PHP5 really running. How? Create you phpinfo.
8. If phpinfo is not displaying any content at all then there must have any problem on the httpd configuration. Here are the things that you should ensure to have on you httpd.conf
LoadModule php5_module modules/libphp5.so ; by default this is placed by PHP installer
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddHandler php5-script .php
AddType text/html .shtml .php
9. Save your changes on the httpd.conf and restart apache.
10. Check again your phpinfo it should display the current PHP and apache settings.
11. By the way sometimes php.ini is not set up so just copy the php.ini to the configuration path check phpinfo for the right path
- on phpinfo you will see
Configuration File (php.ini) Path /usr/local/lib
- copy the recommended php.ini settings
cp /usr/src/php-5.X/php.ini-recommended /usr/local/lib/php.ini
-by the way you should always restart your Apache service after saving any changes you applied on php.ini.
=== Now you have the latest LAMP running.
Hope you find these useful. Thanks, Cheers and God Bless!!!
Actually you can have a LAMP running Apache 2.0, PHP 5.1 and MySQL 5.0 on CentOS 4/RH4 easily with yum. How?
Here it is:
To install apache 2.0
yum --enablerepo=centosplus install httpd
To install mysql 5.1
yum --enablerepo=centosplus install mysql mysql-server
To install PHP 5.1
yum --enablerepo=centosplus install php
Then you are done you have a CentOS 4.x running Apache 2.0 MySQL 5.1 and PHP 5.1. Hmmm quite nice isn't it.
But how about if you really insist to have the latest. Well then here is how.
Of course you have to remove all the old Apache, PHP and MySQL instances. Here's how to do it.
1. First check if they are currently installed
rpm -qa|grep httpd ;to check if Apache is installed
rpm -qa|grep mysql ; to check if mysql is installed
rpm -qa|grep php ; to check if php is installed
2. If they are installed then remove them
yum remove httpd
yum remove mysql
yum remove php
3. Remove the remaining traces or dependencies of it
rpm -qa|grep php
you will see here like
php-common
php-pdo
remove them via
rpm -e php-common php-pdo
do the same thing on httpd and mysql
rpm -qa|grep (packagename)
then remove remaining traces
rpm -e (packagename)
4. Once all is clean we can start downloading all the latest packages for our new LAMP
Installing Apache
1. Goto /usr/src
cd /usr/src
1. Get the latest apache server say 2.2.x
wget http://apache.mirrors.biblionix.com/httpd/httpd-2.2.11.tar.gz
2. Extract it
tar xvzf httpd-2.2.11.tar.gz
3. cd httpd-2.2.11
4. then under the httpd folder do the following
./configure
make
make install
By default the apache is installed at /usr/local/apache2 folder
5. Set the necessary configuration you want for your web server
vi /usr/local/apache2/conf/httpd.conf
in my case I set my document root on /var/www/html
to avoid directoy listing do this
On directory directive you will see this
Options Indexes FollowSymLinks
make it like this
Options -Indexes FollowSymLinks
well enough on httpd configurations we'll have more on our next discussions to follow
6. To make the httd start at boot, we'll put it on Linux services. How?
- copy first the apachectl script from the httpd folder
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
- we put it on under init.d since all start up scripts are under this folder and being executed upon boot
- we're not done yet. Open httpd startup script.
vi /etc/init.d/httpd
- Add the following entries after the second line
# chkconfig: - 85 15
# description: Apache Web server
- let us add it on the Linux services
/sbin/chkconfig --add httpd
- then set it to start on running levels 345
/sbin/chkconfig --level 345 httpd on
- check if it is set well
/sbin/chkconfig --list|grep httpd
- you should see this
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
7. Now start the httpd service by
/sbin/service httpd start
8. to check if it is running
/sbin/service httpd status (only works for apache installed via rpm or yum)
or do
ps aux|grep httpd (works for all so just do this in our case)
- you should see either of the following
root 27093 0.0 0.1 4108 1808 ? Ss 14:31 0:00 /usr/local/apache2/bin/httpd -k start
apache 27114 0.0 0.1 4108 1640 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27115 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27116 0.0 0.1 4120 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27117 0.0 0.1 4108 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27118 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27119 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
-- now you have a running Apache server version 2.2
Installing MySQL
We'll do the RPM way of installing this one.
1. First you have to know what version of CentOS you have and what platform are you working in with.
- to know what platform are you working with issue the command
uname -i ; this will display or echo the platfrom in my case its i386
- to know what OS version are you running with open this file or just do cat
cat /etc/redhat-release ; this will display the OS version in my case it's CentOS release 4.7 (Final)
2. Since we're running i386 platform and version 4.x CentOS we'll download the necessary MySQL rpm packages suitable to this platfrom. In this case it is x86 or Red Hat Enterprise Linux 4 RPM (x86) downloads. Here are the things we need.
- MySQL-server-community-5.1.30-0.rhel4.i386.rpm
- MySQL-client-community-5.1.30-0.rhel4.i386.rpm
- MySQL-devel-community-5.1.30-0.rhel4.i386.rpm
- MySQL-shared-community-5.1.30-0.rhel4.i386.rpm
- so let's download them
wget http://(Mirror-linkname)/(rpmpackagename)
3. Once all neede packages are downloaded we can now install them. Issue the following command
- to install each of the packages issue this
rpm -ivh (packagename)
Ex. rpm -ivh MySQL-server-community-5.1.30-0.rhel4.i386.rpm
4. Then ensure that mysql service can start at boot.
/sbin/chkconfig --list|grep mysql
- you should see this
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- if it is not then make sure it runs / start on run level 345
/sbin/chkconfig --level 345 mysql on
5. Start MySQL service
/sbin/service mysql start
6. By default MySQL root has no password so just set its password say by installing first phpMyAdmin then reset password there or just go using the mysqladmin or mysql console command to reset password.
-- Now you have a running MySQL server version 5.1.x
Installation of PHP
Before we proceed on installing PHP we need the following to be installed first. These packages are known and commonly used on web development such as XML, web service and others
- curl (compile from source or you can do yum)
- curl-devel (if you did yum on curl)
- zlib (compile from source or do yum)
- libxml2 (compile from source or do yum)
- libxml2-devel (if you did yum on libxml2)
- openssl (you can do yum on this one)
- libpng (do yum here)
- libpng-devel (do yum here)
- gd (do yum)
- gd-devel (do yum)
Once all of these package are installed we can proceed on php installation.
1. Get the latest PHP packages from php.net
2. Goto /usr/src
3. Extract it there
4. cd php-5.x/
5. then issue this
./configure --with-mysql --enable-soap --with-apxs2=/usr/local/apache2/bin/apxs --enable-ftp --with-curl --with-curlwrappers --with-zlib --with-gettext --with-gd
make
make install
6. You now have installed PHP 5.x
7. There are things to verify to make PHP5 really running. How? Create you phpinfo.
8. If phpinfo is not displaying any content at all then there must have any problem on the httpd configuration. Here are the things that you should ensure to have on you httpd.conf
LoadModule php5_module modules/libphp5.so ; by default this is placed by PHP installer
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddHandler php5-script .php
AddType text/html .shtml .php
9. Save your changes on the httpd.conf and restart apache.
10. Check again your phpinfo it should display the current PHP and apache settings.
11. By the way sometimes php.ini is not set up so just copy the php.ini to the configuration path check phpinfo for the right path
- on phpinfo you will see
Configuration File (php.ini) Path /usr/local/lib
- copy the recommended php.ini settings
cp /usr/src/php-5.X/php.ini-recommended /usr/local/lib/php.ini
-by the way you should always restart your Apache service after saving any changes you applied on php.ini.
=== Now you have the latest LAMP running.
Hope you find these useful. Thanks, Cheers and God Bless!!!
Subscribe to:
Posts (Atom)