Cara Install Apache, PHP dan MySQL di Ubuntu atau Linux Mint


Cara Install Apache PHP dan MySQL di Ubuntu atau Linux Mint

Pengguna LAMPP/XAMPP mungkin pernah mengalami Apache nya gak bisa running, dengan mendapatkan notif "Another web server already running". Ini mungkin terjadi karena ada yang sedang menggunakan port yang sama (port 80), tapi bukan web server. Namun, biasanya ini terjadi karena apache XAMPP bentrok dengan apache sistem bawaan linux. Untuk meyakinkan, cek via terminal-command: ps -e | grep apache atau: ps -e | grep httpd.

Jadi, daripada Anda pusing dengan ruwetnya LAMPP/XAMPP, lebih baik gunakan saja paket instalasi Apache, PHP, MySQL asli dari repositori Ubuntu (upstream Mint = Ubuntu).

Instalasi via terminal:

1. $ sudo apt-get install apache2
2. $ sudo apt-get install libapache2-mod-php5 (Ubuntu 14.04)
    $ sudo apt-get install libapache2-mod-php7.0 (Ubuntu 16.04)
3. $ sudo apt-get install mysql-server
4. $ sudo apt-get install phpmyadmin

Setelah instal selesai, Apache akan start otomatis via SysV init di Ubuntu 14.04, atau bisa diset start/stop manual misal via command:

$ sudo service apache2 start <------- starting Apache manually
$ sudo service apache2 stop <------- stop Apache manually
$ sudo service apache2 restart <----- restarting Apache manually

MySQL service juga bisa diset start/stop:

$ sudo service mysql start <------- starting MySQL manually
$ sudo service mysql stop <------- stop MySQL manually
$ sudo service mysql restart <----- restarting MySQL manually

Cek service via terminal:

$ sudo service apache2 status <-----cek Apache service
$ sudo service mysql status <------- cek MySQL service

Script PHP atau HTML, ataupun desain web dapat Anda lokasikan di:
/var/www/html/
Akses via web page:
http://localhost/[nama-file-or-nama-folder-desain-web]

phpMyAdmin dapat Anda akses via web page:
http://localhost/phpmyadmin/

Ubuntu 16.04 ada perubahan cara start/stop + cek status, menggunakan "systemd":

Apache service juga bisa diset start/stop:
$ sudo systemctl start apache2 <------- starting Apache manually
$ sudo systemctl stop apache2 <------- stop Apache manually
$ sudo systemctl restart apache2 <----- restarting Apache manually

MySQL service juga bisa diset start/stop:
$ sudo systemctl start mysql <------- starting MySQL manually
$ sudo systemctl stop mysql <------- stop MySQL manually
$ sudo systemctl restart mysql <----- restarting MySQL manually

Cek service via terminal:
$ sudo systemctl status apache2 -l <----- cek Apache service
$ sudo systemctl status mysql -l <------- cek MySQL service


Supaya phpMyAdmin lebih accessible, tambahkan direktip berikut di /etc/apache2/apache2.conf Apache Anda:

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php

<IfModule mod_php.c>
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
</IfModule>
<FilesMatch ".+\.php$">
SetHandler application/x-httpd-php
</FilesMatch>

php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen On
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
</IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
<IfModule mod_authz_core.c>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</IfModule>
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Require all denied
</Directory>

Semoga bermanfaat........

0 Response to "Cara Install Apache, PHP dan MySQL di Ubuntu atau Linux Mint"

Posting Komentar

Related Posts Plugin for WordPress, Blogger...