Wednesday, March 23, 2016

Install NginX PHP5 Mysql-Server on Raspberry

apt-get install nginx php5-fpm php5-mysql mysql-server
nano /etc/nginx/sites-available/default
 Perhatikan bagian ini
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

Ingat, kasih tanda # pada fastcgi_pass 127.0.0.1:9000; karena bentrok dengan yang dibawahnya
Pastikan konfigurasi nginx.conf betul
root@raspberrypi:/home/pi# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:51
nginx: configuration file /etc/nginx/nginx.conf test failed

Kalau salah cek lagi mungkin ada yang keliru dikit, Cek lagi untuk memastikan nginx.conf
root@raspberrypi:/home/pi# nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
 Lalu restart fpm-php nya
root@raspberrypi:/home/pi# /etc/init.d/php5-fpm restart
[ ok ] Restarting php5-fpm (via systemctl): php5-fpm.service.
root@raspberrypi:/home/pi#
Restart nginx
root@raspberrypi:/home/pi# /etc/init.d/nginx restart
[ ok ] Restarting nginx (via systemctl): nginx.service.
root@raspberrypi:/home/pi#

Sekarang buat file /var/www/html/info.php yang isinya
<?php phpinfo();?>
 Lalu buka browser sampai muncul seperti ini.


Selanjutnya bisa anda install wordpress, dll.

Tambahan :

Setting agar tidak bisa upload file dot php untuk menangguangi phpshell dan me-restrict file yang terhiden seperti .htaccess
tambahkan berikut ini pada file /etc/nginx/sites-available/default tadi. Taruh dibawah
fastcgi_pass unix:/var/run/php5-fpm.sock;
}

        # Deny access to any files with a .php extension in the uploads directory
        # Works in sub-directory installs and also in multisite network
        # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
        #
        location ~* /(?:uploads|files)/.*\.php$ {
                deny all;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one

        location ~ /\.ht {
                deny all;
        }

No comments:

Post a Comment