Wednesday 29 September 2021

Cara install nginx,mysql dan php di macbook OS Catalina

Cara install nginx,mysql dan php di macbook OS Catalina


Langsung aja jalankan perintah ini :

Install nginx

  1. brew update
  2. brew install nginx
  3. Atur konfigurasi nginx untuk folder root webservernya :
  4. brew services start nginx (restart nginx) atau nginx -s reload (reload konfigurasi saja)

server {

        listen       80;

        server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {

            root   html;

            index  index.html index.htm index.php;

        }


Penjelasan

            root   html; - - bisa diganti dengan path folder yang diinginkan

            index  index.html index.htm index.php; — — tambahkan index.php




Install mysql

  1. brew install mysql
  2. brew services start mysql
  3. Pasang password dimysql dengan: mysql_secure_installation
  4. Ketik Y untuk menggunakan password
  5. Pilih tingkat kompleksitas password
  6. PIlih y sampai selesai


Install php

  1. brew install php
  2. vim /usr/local/etc/nginx/nginx.conf 
  3. ganti location php seperti di bawah ini

 location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

            include        fastcgi_params;

        }


  1. brew services start php
  2. brew services list - - untuk lihat services yang sedang berjalan
  3. coba masukkan file index.php berikut ke folder /usr/local/var/www (folder default)

<html>

  <head>

    <title>domain_anda website</title>

  </head>

  <body>

    <h1>Hello World!</h1>

    <?php

        $pass = md5(‘pass’);

        print $pass;

    ?>


    <p>This is the landing page of <strong>domain_anda</strong>.</p>

  </body>

</html>

  1. Ketik localhost/index.php di url

1a1dc91c907325c69271ddf0c944bc72 

Hello World!

This is the landing page of domain_anda.

No comments: