Install LAMP (Apache2, PHP5 dan MySQL Support) CentOS

Install LAMP (Apache2, PHP5 dan MySQL Support) CentOS

  • admin
  • 29 Desember 2014

Install LAMP

LAMP adalah singkatan dari [L]inux, [A]pache, [M]ySQL dan [P]HP. Dimana dalam bahasa pemrograman keempat element tersebut tidak pernah diabaikan. Contohnya saja dalam pembuatan website yang menggunakan database, dimana LAMP tidak bisa terpisahkan satu sama lain. Jika salah satunya hilang maka website database tersebut dijamin tidak berjalan sebagaimana mestinya. Dalam tutorial ini saya mau berbagi bagaimana cara menginstall LAMP di CentOS dengan menggunakan yum.

MySQL 5

MySQL 5 adalah server tempat menampung database. Cara installnya adalah menggunakan command yum di root ssh:

yum -y install mysql mysql-server

Setelah selesai menginstall kita jalankan server MySQL nya dan mengatur chkconfig agar server tetap UP walaupun ada booting system.

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

Selanjutnya membuat password SQL: mysql_secure_installation Maka akan tampil menu seperti ini:

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):

Tekan 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.

Kemudian tekan enter saat muncul seperti ini:

Set root password? [Y/n]

Dibawahnya baru set password MySQLnya. Setelah itu tekan Enter sampai proses setting MySQL selesai.

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] ... 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]
- 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]
... 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!

Apache2

Selanjutnya adalah menginstall Apache:

yum -y install httpd

Sama seperti mysql, anda harus menjalankan chkconfig agar server start otomatis saat direboot.

chkconfig --levels 235 httpd on

kemudian jalankan service apache:

/etc/init.d/httpd start

Sekarang cek apakah Apache nya sudah berjalan dengan membuka browser kemudian ketikkan alamat IP server anda.

PHP

Untuk menginstall service PHP jalankan command:

yum -y install php

Sekarang restart Apache.

/etc/init.d/httpd restart

Sekarang untuk tambahan aja, kadang-kadang menginstall mysql, php dan apache saja tidak cukup. Untuk itu mari kita install mysql support yang lain.

yum -y install php-mysql php-pecl-apc php-imap php-xml php-xmlrpc php-mcrypt php-mssql curl-devel

Kemudian restart kembali apache:

/etc/init.d/httpd restart

phpMyAdmin

Import RPMforge GPG key:

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
yum -y install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Install phpmyadmin:

yum -y install phpmyadmin

Setelah diinstall coba buka phpmyadminnya melalui browser. Jika bisa dibuka berarti alhamdulilah. Tapi kalo ada tulisan permission denied atau 403, silahkan edit phpmyadmin.conf. vi /etc/httpd/conf.d/phpmyadmin.conf

#  Web application to manage MySQL
#

#
#  Order Deny,Allow
#  Deny from all
#  Allow from 127.0.0.1
#

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin
Alias /mysqladmin /usr/share/phpmyadmin

Tambahkan code berikut tepat dibawah line "Allow from 127.0.0.1":

Allow from all
Allow from ::1

Lanjut, Restart Apache:

/etc/init.d/httpd restart

Dan akhirnya selesai juga penginstallan LAMP di system anda. Jika anda ingin menginstall LAMP di server Ubuntu, silahkan ikuti Tutorial "Cara install LAMP di Ubuntu Server".

Login