Skip to content

Instantly share code, notes, and snippets.

@ngocquyhoang
Last active August 30, 2019 10:41
Show Gist options
  • Save ngocquyhoang/21414716de852b91b24a151f4d9190df to your computer and use it in GitHub Desktop.
Save ngocquyhoang/21414716de852b91b24a151f4d9190df to your computer and use it in GitHub Desktop.
Setup Server

Cài đặt LEMPP trên Ubuntu

Tham khảo: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04

Cài Nginx

sudo apt update
sudo apt install nginx

Kiểm tra bằng cách truy cập vào

http://server_domain_or_IP

nếu trả về status code là 200 là

Cài DATABASE

sudo apt install mysql-server
sudo mysql_secure_installation
# => thực hiện các step tiếp theo đển hoàn tất cài đặt

Cài PHP

sudo apt install php-fpm php-mysql

Setup virual host

sudo nano /etc/nginx/sites-available/default
server {
        listen 80;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name example.com;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}
sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/
sudo systemctl reload nginx

Source code đặt tại

/var/www/html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment