Apache LAMP Red hat linux

Install LAMP on Redhat / Centos 6

LAMP කියන්නේ open-source software කිහිපයක එකතුවක්. ඒ කියන්නේ Linux, Apache HTTP Server, MySQL database, and PHP/Perl/Python).

මේ tutorial එකේදි මම ඔයාලට කියලා දෙන්නේ කොහොමද RHEL/CentOS 6.X වල LAMP install කරන්නේ කියලා.

මේකෙදි මගේ server එකේ hostname එක test.ideus.lk. server IP එක වෙන්නේ 192.168.1.101/24.

මුලින්ම කරන්න පොඩි දෙයක් තියෙනවා.EPEL Repository එක අපේ server එකට configure කරගන්න ඕන. Repository ගැන මම ඉස්සරහට කියලා දෙනවා.දැනට ඔයාලගේ OS එකට ගැලපෙන Repository එක පල්ලෙහා command එකෙන් setup කරගන්නකො.

## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

ඉතින් LAMP  අපි පිළිවෙලට setup කරගෙන යමු. linux, ඒ කියන්නේ REDHAT හරි CENTOS හරි අපි දැනටම install කරලනේ තියෙන්නේ.ඒ නිසා අපි ඊළගට APACHE, ඒ කියන්නේ web werver එක setup කරමු.

yum update
yum install vim wget -y
yum install httpd -y
service httpd start
chkconfig httpd on

දැන්නම් apache web service eka setup වෙලා තියෙන්නේ.ඒ උනාට එළියේ ඉදන්, ඒ කියන්නේ local host එකෙන් පිට ඉදන් මේ server එකේ වෙබ් service එක access කරන්න බැ. මොකද අපේ server එකේ firewall එකෙන් වෙබ් access කරන ports block කරන නිසා. සාමාන්යෙන් වෙබ් services වලට අපි ports දෙකක් පාවිච්චි කරනවා. port 80 HTTP වලටත් port 443 HTTPS වලටත්.

ඉතින් අපි මේ port දෙකට අපේ firewall එකෙන් ඒ කියන්නේ IP tables වලින් access හදන්න ඕන. IP tables ගැන මම ඔයාලට ඉස්සරහට කියලා දෙන්නම්. දැනට /etc/sysconfig/iptables කියන file එකට මේ firewall rule දෙක දාල වැඩේ ගොඩ දාගමුකො.

vim /etc/sysconfig/iptables

[add this lines]

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 443 -j ACCEPT

එට පස්සේ IP tables service එක restart කරන්න ඕන අපි add කරපු firewall rule දෙක effect වෙන්න.

service iptables restart

ඊට පස්සේ තියෙන්නේ පොඩ්ඩක් test කරලා බලන්න. දැන් ඔයාගේ windows machine එකෙන් හරි වෙන machine එකක ඉදන් හරි අපි setup කරපු server එකේ IP එක web browser එකේ ගැහුවම පල්ලෙහා පේන විදියට apache test page එක පෙන්න ඕන.

apache test page

 

ඊළගට setup කරන්න තියෙනේ mysql.ඒ කියන්නේ database service එක දාන එක.පල්ලෙහා command දෙක run කරන්න witharai තියෙන්නේ.

yum install mysql mysql-server -y
service mysqld start

තව දෙයක් තියෙනවා කරන්න.දැන් මෙහෙම yum install ගහල setup කරාට server එක shutdown කරලා up කලොත් හරි reboot කලොත් හරි මේ services auto start වෙන්නේ නැ.එකට කරන්න තියෙන්නේ chkconfig  කියන command එකෙන් අපේ mysql service එක auto start වෙන්න සෙට් කරන්න ඕන පල්ලෙහා තියෙන command එකෙන්.

chkconfig mysqld on

හරි, දැන් තියෙනවා අපේ mysql server එකේ පොඩි changes ටිකක් කරන්න.සාමාන්යෙන් mysql server එක setup උනාම එකට root password එකක් නැතුව setup වෙන්නේ.ඉතින් අපි mysql root password එක සෙට් කරලා, root ගෙන් remote ලොග් වෙන එක නවත්තන්න ඕන.පහල තියෙන command එක type කලාම ඒ ටික කරගන්න පුලුවන්.

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):     ## Press 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]     ## Press Enter ##
New password:                ## Enter new password ##
Re-enter new password:       ## Re-enter new password ##
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]     ## Press 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]     ## Press 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]     ## Press 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]     ## Press 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!

හරි.ඊළගට අපිට තියෙන්නේ PHP install කරලන්න. yum install වලින් setup කරලා apache restart කරන්න තියෙන්නේ.

yum install php php-mysql -y
service httpd restart

දැන්නම් LAMP install කරන වැඩේ ඉවරයි.අපිට ඕනනම් phpmyadmin දාගන්න පුළුවන් අපේ mysql database administration වැඩ වලට.එකත් මම මෙහෙමම කියලා දෙන්නම්.

yum install phpmyadmin -y

ඊට පස්සේ පොඩි වෙනස්කම් ටිකක් තියෙනවා config file එකේ කරන්න.

vim /etc/httpd/conf.d/phpMyAdmin.conf

config file එක open කලාට පස්සේ එකේ <Directory /usr/share/phpMyAdmin/>  වලින් පටන් අරන් </Directory> වෙනකල් තියෙන කොටස comment කරලා දාන්න.comment කරන්නේ ඒ line එක ඉස්සරහට දාන්න තියෙන්නේ.

ඊට පස්සේ phpmyadmin වල Authentication type එක HTTP වලට දාන්න ඕන.

cp /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php 
vim /etc/phpMyAdmin/config.inc.php

මෙතන  “cookie” කියන එක  “http” කරලා save කරන්න.

[…]
/* Authentication type */
$cfg[‘Servers’][$i][‘auth_type’] = ‘http’;
[…]

ඊට පස්සේ තියෙන්නේ අපේ web service එක, ඒ කියන්නේ apache restart කරන එක.

service httpd restart

ආ තව දෙයක්.phpmyadmin setup කලට access කරන හැටි කියන්න බැරි උනානේ.

ඔයාගේ [server ip]/phpmyadmin වලින්  phpmyadmin වලට යන්න පුළුවන්.එකට ලොග් වෙන්න අපි කලින් mysql setup කරනකොට දාපු root password එක use කරන්න.

phpMyAdmin

ඇති දෙයක් නෑ.!!!!

ඉතින් ඔයාලට මේ page එකෙන් ඉස්සරහට දිගටම මේ වගේ tutorials බලන්න පුළුවන්. like එකක් දාල ඔයාලගේ යාළුවන්ට බලන්න share කරන්න.

වැරදි / වෙනස් වෙන්න මොනවහරි තියෙනවනම් පහල comments වල දාන්න.

මේ post ඔක්කොම ඔයාලට www.sysadmin.lk වෙබ් එකෙනුත් බලන්න පුළුවන්. අලුත් tutorial එකක් එක්ක ලගදීම එන්නම්. 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *