Merubah Directory www apache di linux mint – raspbian – ubuntu

Merubah Directory www apache di linux mint – raspbian – ubuntu

Artikel ini untuk penggunaan linux dicoba pada raspbian dan linux mint.

Mungkin kita merasa perlu untuk melakukan perubahan folder direktori apache dari yang sebelumny di /var/www/public_html/ ke folder yang kita inginkan misalnya klo saya pengennya menaruh file php atau proyek aplikasi web di /home/www/ . penempatan folder tersebut juga memudahkan code editor misalnya sublime atau vscode dalam mengedit file tanpa harus kita assign code editor tersebut dengan perintah sudo di linux.

susah bagi kita untuk mengedit source kode yang disimpan pada folder default public html apache yakni /var/www/public_html/

1. Tambahkan folder www di directory home

tambahkan folder www di directory home sehingga di folder home akan ada folder yang nantinya akan digunakan sebagai folder yang menggantikan folder dari default apache.

2. Arahkan symlink dari folder www apache ke folder directory home yang baru dibuat

folder default apache www di : var/www maka anda bisa tambahkan symlink dengan cara berikut

sudo ln -s /var/www /home/www
3. Lakukan konfigurasi apache

konfigurasi ini menggunakan apache2 lokasi folder pada

/etc/apache2/httpd.conf

UPDATE 2017

untuk versi baru apache maka filenya yang perlu diupdate adalah pada  apache2.conf

untuk melakukan pengeditan silahkan ketik  sudo nano  /etc/apache2/sites-enabled/000-default.conf
 and rubah line pada block

<Directory /var/www >

ini kodenya

<VirtualHost *:80>
      # The ServerName directive sets the request scheme, hostname and port that
      # the server uses to identify itself. This is used when creating
      # redirection URLs. In the context of virtual hosts, the ServerName
      # specifies what hostname must appear in the request's Host: header to
      # match this virtual host. For the default virtual host (this file) this
      # value is not decisive as it is used as a last resort host regardless.
      # However, you must set it for any further virtual host explicitly.
      #ServerName www.example.com

      ServerAdmin webmaster@localhost
      #DocumentRoot /var/www/html
      DocumentRoot /home/muhammad/www

      # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
      # error, crit, alert, emerg.
      # It is also possible to configure the loglevel for particular
      # modules, e.g.
      #LogLevel info ssl:warn

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      # For most configuration files from conf-available/, which are
      # enabled or disabled at a global level, it is possible to
      # include a line for only one particular virtual host. For example the
      # following line enables the CGI configuration for this host only
      # after it has been globally disabled with "a2disconf".
      #Include conf-available/serve-cgi-bin.conf



        <Directory />
                Options FollowSymLinks
                AllowOverride All
       </Directory>
      <Directory /home/muhammad/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>


</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

pada kode konfig diatas perubahan yang perlu dilakukan diberikan tanda cetak tebal.  Jika masih juga bandel bisa menambahkan langkah berikut

  1. rubah baris  AllowOverride None to AllowOverride all.
  2. Restart the apache server dengan perintah : sudo service apache2 restart
4. Uji Coba

Anda perlu ujicoba dengan membuat file baru php dengan menambahkan satu file di folder /home/www dengan nama file info.php

dengan code berikut :

<?php 
   phpinfo();

 

Requested file not found in this server

Exit mobile version