Anda di halaman 1dari 5

[TUTORIAL] How To easy install Apache 2.

4
and PHP 7 on Windows
Menginstall Apache HTTP Server
Untuk menginstall Apache HTTP Server, pertama install Visual C++ Redistributable,
kemudian ekstrak file zip yang telah didownload ke dalam folder yang kita inginkan, misalkan
ke C:/WAMP/. Berikutnya, kita perlu mengedit file httpd.conf yang terletak pada folder
Apache24/conf/httpd.conf. Buka file tersebut dengan notepad, kemudian ubah baris-baris
berikut:

ServerRoot, adalah lokasi direktori utama http server kita. Ubah nilainya menjadi
C:/WAMP/Apache24
ServerAdmin, adalah email webmaster. Masukkan saja email Anda ke sini.
ServerName, adalah nama server kita. Hapus tanda komentar (#) dan masukkan nama
domain anda, Karena saya hanya menggunakan server secara lokal, saya biarkan nama
server tersebut sama seperti semula.
DocumentRoot, adalah lokasi di mana kita meletakkan file-file web kita. Ubah nilainya
menjadi C:/WAMP/htdocs.
htdocs directory, tepat di bawah baris DocumentRoot, terdapat konfigurasi <Directory>
berformat XML untuk DocumentRoot. Ubah juga path Directory ini
menjadi "C:/WAMP/htdocs". Ubah juga perintah AllowOverride di dalamnya
dari None menjadi All. Agar kita dapat menggunakan file konfigurasi .htaccess dalam
folder htdocs kita.
rewrite_module, apabila suatu saat kita memerlukan perintah RewriteEngine pada
file .htaccess kita atau jika Anda menggunakan framework CodeIgniter, Anda perlu
menghapus tanda komentar pada perintah LoadModule berikut: LoadModule
rewrite_module modules/mod_rewrite.so.
IfModule dir_module, adalah file default pada suatu direktori yang akan dibaca apabila
ada permintaan pada alamat suatu direktori. Ubah nilai di dalamnya
menjadi DirectoryIndex index.php index.html index.htm.
Ubah C:/Apache24, Saya tidak benar-benar mengerti konfigurasi lain di dalam
httpd.conf, jadi saya merename semua C:/Apache24 menjadi C:/WAMP/Apache24 untuk
menyesuaikan dengan struktur direktori saya.

Pada perintah DocumentRoot, kita mengatur pathnya menjadi C:/WAMP/htdocs yang berada di
luar folder Apache24. Lokasi asal folder htdocs sebetulnya berada di dalam folder Apache24. Di
dalamnya terdapat suatu file index.html sederhana yang menampilkan "It Works!" pada layar.
Pindahkan folder ini dari C:/WAMP/Apache24/htdocs ke C:/WAMP/htdocs. Kemudian jalankan
command prompt (ketikkan cmd pada start menu) dan ketikkan perintah berikut:

cd \wamp\apache24\bin, untuk mengubah direktori yang sedang aktif


httpd.exe -k install -n Apache2.4, untuk menginstall http server, sehingga ia akan selalu
dijalankan setiap kali kita menyalakan komputer.
httpd.exe -k start -n Apache2.4, untuk menjalankan http server kita.

Setelah itu, buka browser dan ketikkan "localhost" pada url. Jika tampil tulisan "It Works!",
maka kita telah berhasil menginstall Apache http server.

Jika terdapat error ketika menginstall, ketikkan httpd.exe -k uninstall -n


Apache2.4 untuk menguninstall servis httpd, kemudian perbaiki error yang disebutkan.
Kemudian coba install dan jalankan kembali http server Anda.

Install PHP 7 on Windows


Sebelum install php, download terlebih dahulu php sesuai dengan os 32bit atau 64 bit. Silahkan
kunjungi http://windows.php.net/download/. Setelah masuk ke web php download pilih yang zip.

Extrak file php-7.0.6-Win32-VC14-x64.zip,

Buat foldercopy semua isi dari folder zip


Create a folder named "php7" then extract the file php-7.0.6-Win32-VC14-x64.zip into the
folder and move it to C:\
Configure Apache to use PHP
Open the Apache Configuration file C:\Apache24\conf\httpd.conf
Copy the following lines on the top of the file:

AddHandler application/x-httpd-php .php


AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
PHPIniDir "c:/php7"

In the section <IfModule dir_module> add the line index.php and place it before index.html
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

Save all. Now rename the file C:\php7\php.ini-development to C:\php7\php.ini

Enabling mod_rewrite for URL rewriting


Open the Apache Configuration file C:\Apache24\conf\httpd.conf
Find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash #
Find any additional occurrences of the line "AllowOverride None" and change it to
"AllowOverride All"

Configuring PHP with MySQL


Edit the php.ini file and uncomment the extension directory. Remove the ";" to uncomment:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

Uncomment the following lines, this will enable the starting of the MySQL modules
extension=php_mysqli.dll
extension=php_pdo_mysql.dll

and these other lines if you use the installation in a development environment
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_openssl.dll
Uncomment the error_log to enable file logging

; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
error_log = c:\php7\php_errors.log

Save the file changes.

IMPORTANT! Set your PATH for Windows to find PHP


Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";").
Example: ";C:\php7"
Click Okay.

How to check if php is installed


Create the following text file C:\Apache24\htdocs\phpinfo.php

<?php

echo phpinfo();

?>
view raw info.php hosted with by GitHub

Restart Apache and then go to your browser and write http://localhost:8181/phpinfo.php this
page should show the details of your PHP installation.

Register Apache Service


If you want to register Apache as a Windows Service, open a command prompt and type:

C:\Apache24\bin\httpd -k install

If do not want Apache starting automatically at start-up/reboot type:

C:\> sc config Apache2.4 start= demand

Anda mungkin juga menyukai