29 Maret 2014

Cara Install Web Server (LAMP) di openSUSE

LAMP adalah singkatan dari Linux, Apache, MySQL/MariaDB, dan PHP/Perl, yaitu software yang paling banyak digunakan untuk server web. Artikel dibawah ini akan membahas mengenai cara install server web LAMP di openSUSE.

Instal LAMP

Untuk menginstal LAMP di openSUSE sangatlah mudah, bisa menginstal sekaligus dengan pattern "lamp_server" atau menginstal paket-paketnya satu-persatu. Kali ini saya menginstal menggunakan pattern (kelompok software) tersebut via zypper.

Buka terminal dan install dengan perintah:
zypper install -t pattern lamp_server

Perintah tersebut akan menginstal paket-paket seperti Apache2, MariaDB, PHP5, dan Modul http server YaST sekaligus beserta dependensinya. Lebih praktis kan?

Mengaktifkan LAMP


Secara default, service-service paket tersebut tidak secara otomatis dijalankan. Kita harus menjalankannya sendiri.

Menjalankan Apache2

Jalankan perintah:
systemctl start apache2.service
systemctl enable apache2.service

Buka peramban web (misalnya firefox)
Ketikkan alamat "localhost" tanpa tanda kutip pada kolom alamat. Jika muncul tampilan "It works!" artinya Apache2 sudah berjalan.

apache2-opensuse


Root dokemen Apache2 di openSUSE ada di folder: /srv/www/htdocs/

Kita juga bisa menguji apakah PHP sudah terinstal sebagaimana mestinya dengan cara membuat file phpinfo pada root dokumen Apache.
nano /srv/www/htdocs/testphp.php

Tambahkan baris berikut:
<?php
phpinfo();

Simpan dengan menekan CTRL + X lalu tekan Y + Enter
Jika keluar informasi berikut, artinya PHP memang sudah terinstal dengan benar.

phpinfo-opensuse

Menjalankan MySQL/MariaDB

Jalankan perintah:
systemctl start mysql.service
systemctl enable mysql.service

Secara default, password MySQL kosong. Untuk alasan keamanan, Anda bisa memberinya password. Jalankan perintah berikut:
mysql_secure_installation

Maka akan tampil output seperti berikut:
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!



In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, 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 MariaDB

root user without the proper authorisation.



Set root password? [Y/n] <== Tekan Y

New password:         <== Masukkan password

Re-enter new password:   <== Masukkan password sekali lagi

Password updated successfully!

Reloading privilege tables..

 ... Success!



By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB 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]  <== tekan Y

 ... 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] <== Tekan Y

 ... Success!



By default, MariaDB 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]  <== Tekan Y

 - 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]  <== Tekan Y

 ... Success!



Cleaning up...



All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.



Thanks for using MariaDB!

Sampai tahap ini Anda sudah memiliki server web sendiri di localhost. Taruh konten web anda di folder dokumen root Apache2 di /srv/www/htdocs/ Jika anda ingin server web anda bisa diakses di internet atau dari komputer lain, anda harus mengijinkan apache2 membuka port 80. Edit di SuSEfirewall:
nano /etc/sysconfig/SuSEfirewall2

Cari kata:
FW_CONFIGURATIONS_EXT=""

Ganti dengan:
FW_CONFIGURATIONS_EXT="apache2"

Simpan dengan menekan CTRL + X lalu tekan Y + Enter Lalu restart servicenya:
systemctl restart SuSEfirewall2.service

Akses web menggunakan IP atau hostname komputer kita dari komputer lain


EmoticonEmoticon