Server Lesson: Install LEMP

Saya menggunakan server Debian kerana hampir sama dengan Raspbian pada Raspberry Pi LAMP Web Server. LEMP bermaksud (L) Linux operating System, (E) Nginx web server, (M) MariaDB database dan (P) PHP.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt install ufw
$ sudo ufw enable
$ sudo ufw allow 22
$ sudo ufw allow 80
$ sudo ufw app list
$ sudo apt-get install nginx
$ systemctl status nginx
$ sudo apt install php-fpm php-mysql php-zip php-gd php-xml php-xmlrpc php-curl php-intl php-mbstring php-soap
$ sudo mkdir -p /var/www/your_domain
$ sudo chown -R www-data:www-data /var/www/your_domain
$ sudo chmod -R 755 /var/www/your_domain
$ nano /var/www/your_domain/index.html

Masukkan source code untuk index.html

<html>
    <head>
        <title>Welcome to your_domain</title>
    </head>
    <body>
        <h1>Success! Your Nginx server is successfully configured for <em>your_domain</em>.</h1>
	<p>This is a sample page.</p>
    </body>
</html>
$ nano /etc/nginx/sites-available/your_domain
server {
    listen 80;
    listen [::]:80;

    root /var/www/your_domain;
    index index.php index.html index.htm;

    server_name your_domain;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
}
$ sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
$ sudo nano /etc/nginx/nginx.conf
Remove # for server_names_hash_bucket_size
$ sudo nginx -t
$ sudo systemctl restart nginx

$ sudo apt install mariadb-server
$ sudo mysql_secure_installation
$ sudo mysql -u root -p
$ create database exampledb;
$ create user 'exampleuser'@'localhost' identified by 'examplepassword';
$ grant all privileges on exampledb.* to 'exampleuser'@'localhost';
$ flush privileges;
$ quit

Rujukan lain:

  1. https://www.digitalocean.com/community/tutorials/initial-server-setup-with-debian-10
  2. https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-debian-10
  3. https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.