Membangun Web Server Centos (LAMP)

LAMP adalah singkatan Linux,? Apache, MySQL, PHP. Tutorial ini menunjukkan bagaimana Anda dapat memasang webserver Apache2 di server Centos dengan dukungan PHP5 (mod_php) dan dukungan MySQL.

1. Instalasi MySQL 5.0
Pertama kita menginstal MySQL 5.0 seperti ini:
yum install mysql mysql-server -y
Lalu membuat link startup sistem untuk MySQL (sehingga MySQL dijalankan secara otomatis setiap kali sistem boot) dan mulai server MySQL:
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
Set password untuk account root MySQL:
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):
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!

2. Install Apache2
yum install httpd -y
Sekarang mengkonfigurasi sistem anda untuk memulai Apache pada saat boot...
chkconfig --levels 235 httpd on
/etc/init.d/httpd start
Sekarang langsung browser Anda untuk http://IP_ADDRESS, dan anda akan melihat halaman placeholder Apache2: Dokumen root Apache default adalah /var/www/html di CentOS, dan file konfigurasi adalah /etc/httpd/conf/httpd.conf. Tambahan konfigurasi disimpan di /etc/httpd/conf.d/ direktori.

3. Install PHP5
Anda dapat menginstall PHP5 dengan perintah
yum install php -y
kemudian restart apache
/etc/init.d/httpd restart
4. Pengujian PHP5 / Instalasi Mendapatkan Detail Tentang PHP5 Anda
Dokumen root dari situs web default adalah /var/www/html. Sekarang kita akan menciptakan sebuah file PHP kecil (info.php) dalam direktori itu dan menyebutnya di browser. File akan menampilkan banyak detail yang berguna tentang instalasi PHP , seperti versi PHP yang diinstal.
nano /var/www/html/info.php
<?php phpinfo(); ?>
Sekarang kita sebut bahwa file dalam browser misalnya http://IP_ADDRESS/info.php
Seperti yang Anda lihat, PHP5 bekerja melalui Apache 2.0 Handler, seperti ditunjukkan pada baris Server API. Jika Anda menggulir ke bawah, Anda akan melihat semua modul yang telah diaktifkan di PHP5. MySQL tidak terdaftar di sana yang berarti kita tidak memiliki dukungan MySQL di PHP5 belum.
5. Dukungan MySQL Mendapatkan Dalam PHP5
Untuk mendapatkan dukungan MySQL di PHP, kita dapat menginstal paket php5-mysql. Ini adalah ide yang baik untuk menginstal beberapa modul PHP5 lainnya serta Anda mungkin membutuhkannya untuk aplikasi Anda. Anda dapat mencari modul PHP5 yang tersedia seperti ini:
yum search php
Pilih yang Anda butuhkan dan menginstalnya seperti ini:
yum install php-cli php-mysql php-mbstring php-gd php-pdo php-xmlrpc php-mhash php-mcrypt -y

Sekarang restart Apache2:
/etc/init.d/httpd restart
Sekarang reload http://IP_ADDREES/info.php di browser Anda dan gulir ke bawah ke bagian modul lagi. Anda sekarang harus menemukan banyak modul baru di sana, termasuk modul MySQL

6. phpMyAdmin
phpMyAdmin adalah antarmuka web di mana Anda dapat mengatur database MySQL. Ini adalah ide yang baik untuk menginstalnya, Pertama kita memungkinkan rpmforge repositori pada sistem CentOS kami sebagai phpMyAdmin tidak tersedia di repositori resmi CentOS 5.3:
Jika system anda x86_64/64bit:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
Apabila i386/32bit systems:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Sekarang install Phpmyadmin dengan perintah
yum install phpmyadmin -y
Sekarang kita konfigurasikan phpMyAdmin. Kami mengubah konfigurasi Apache agar phpMyAdmin yang memungkinkan koneksi tidak hanya dari localhost:
nano /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
Selanjutnya ubah authentication in phpMyAdmin dari cookie ke http:
nano /usr/share/phpmyadmin/config.inc.php
[...]

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';

[...]

restart apache
/etc/init.d/httpd restart
Setelah itu, Anda dapat mengakses phpMyAdmin di http://ipserver/phpmyadmin/

Apakah Jawaban ini membantu?

 Cetak Artikel Ini

Baca Juga

Redirect HTTP Menjadi HTTPS

Jika anda sudah memiliki atau membeli Sertifikat SSL pilihan anda namun anda memiliki kesulitan...

Powered by WHMCompleteSolution