Posts

Hướng dẫn: Cài đặt hoàn chỉnh Nodejs app lên VPS Ubuntu - Phần 2

Chạy app như dịch vụ, serve app qua Nginx reversed proxy và bật HTTPS Tóm tắt phần 1 : Bạn đã cài các phần mềm cần thiết để chạy app: NodeJS, MongoDB, Nginx, Git. App deploy bằng source từ Git host, và clone về tại /apps/my-node-app App đã được build và chạy tại port 3000 của server Hạn chế quyền truy cập của app Đây là bước không bắt buộc, tuy nhiên tôi khuyến cáo không nên bỏ qua, nhất là bạn đang truy cập vào VPS bằng tài khoản root. Chúng ta sẽ tạo một Linux user mới và gán cho thư mục của app. # Tạo một Linux user mới, nên dùng tên của app và không để khoảng trắng sudo useradd my-node-app # Chuyển quyền sở hữu (owner) thư mục app và các thư mục con cho user mới sudo chown -R my-node-app /apps/my-node-app Sh Copy Trong bước tiếp theo, khi chạy app như dịch vụ, app sẽ được chạy với quyền của user mới này để hạn chế quyền truy cập của app lên các thư mục hệ thống. Chạy app như dịch vụ Tiếp theo chúng ta sẽ cài đặt để chạy app như dịch vụ và tự đ...

Hướng dẫn: Cài đặt hoàn chỉnh Nodejs app lên VPS Ubuntu - Phần 1

Image
Cài đặt NGINX, Git, NodeJS, MongoDB, và Keystone app lên server Ubuntu 16.04 LTS Giới Thiệu NodeJS tuy phát triển mạnh mẽ những năm gần đây nhưng tại Việt Nam vẫn còn ít lựa chọn để triển khai (deploy) lên Internet cho công chúng. Các dịch vụ “app engine” cho NodeJS của nước ngoài như Heroku , Nodejitsu , now.sh … khó tiếp cận cho developer ở Việt Nam. Ngoài ra các dịch vụ trên còn nhiều hạn chế chẳng hạn: chưa có data center đặt tại Việt Nam, không kèm giải pháp database hoặc nếu có cũng là dạng add-on. Để cài đặt một web app viết bằng NodeJS, cách đơn giản nhất và tiết kiệm chi phí nhất hiện nay chính là sử dụng Cloud VPS 1 . Cloud VPS là một server toàn quyền được ảo hóa trên một server vật lý, có tài nguyên và băng thông được dành riêng. Ở Việt Nam, hiện đã có nhiều nhà cung cấp dịch vụ Cloud VPS với chi phí khá tiết kiệm (cấu hình thấp nhất có chi phí khoảng 150k/tháng). (Vì đây là bài hướng dẫn kỹ thuật nên tôi sẽ không giới thiệu cụ thể nhà cung cấp nào). Tro...

How To Configure Nginx to Use Custom Error Pages on CentOS 7

Image
Introduction Nginx is a high performance web server capable of serving content with flexibility and power. When designing your web pages, it is often helpful to customize every piece of content that your users will see. This includes error pages for when they request content that is not available. In this guide, we’ll demonstrate how to configure Nginx to use custom error pages on CentOS 7. Prerequisites To get started on with this guide, you will need a non-root user with sudo privileges. You can set up a user of this type by following along with our initial set up guide for CentOS 7 . You will also need to have Nginx installed on your system. Learn how to set this up by following this guide . Creating Your Custom Error Pages We will create a few custom error pages for demonstration purposes, but your custom pages will obviously be different. We will put our custom error pages in the /usr/share/nginx/html directory where CentOS’s Nginx sets its de...

Nano Editor Learn

NOTE: Any command prefixed with a caret symbol (^) means to use the Ctrl key (e.g., ^G means to press the Ctrl+G keys at the same time). ^G     nano help ^A     move to beginning of line in nano ^E     move to end of line in nano ^Y     move down a page - next page in nano ^V     move up a page - previous page in nano ^_     move to a specific line (^_^V moves to the top of the file, ^_^Y to the bottom) ^C     find out what line the cursor is currently on ^W    search or find some text in nano ^D     delete character currently under the cursor ^K     delete line in nano, nano remove line Also for remove or clear or delete some content or multiple lines you can select lines with your mouse and then use CTRL+K. ^O     save file in nano (you will be ...

How to Install and Configure Nginx on CentOS 7

Image
What is Nginx? Nginx (pronounced ‘engine X’) is an alternative to Apache and is considered to be one of the most popular HTTP web servers in the world. As opposed to Apache, Nginx tends to consume fewer resources and improves server responsiveness. Its event-driven design is what makes it resource-friendly. Above all, it allows admins to set up advanced configurations and can deal with a high load of concurrent connections. Besides being a good fit for an HTTP web server, Nginx also works as a reverse proxy , load balancer, and standard mail server. In this article, you will learn how to install and configure Nginx on CentOS 7 . Prerequisites A CentOS self-managed server or VM A Domain. You will need to connect a domain to your Nginx web server Sudo or root privileges [root@user ~] SELinux set up properly How to Install Nginx on CentOS 7 Generally, CentOS is the preferred distribution package in the hosting industry. Currently, CentOS 8 is the latest...

Những lệnh Linux cơ bản ai cũng cần biết

Image
Cũng giống như hệ điều hành Windows, khi sử dụng Linux bạn cũng nên tìm hiểu các lệnh Linux cơ bản để thực hiện các thao tác nhanh chóng và dễ dàng hơn. Dưới đây là một số lệnh cơ bản trên Linux bạn nên biết. Với một số lệnh bên dưới, bạn sẽ thấy các bộ lệnh với giải thích đơn giản, ví dụ minh họa cụ thể giúp cho bạn hoặc những người dùng Linux mà bạn đang hỗ trợ sử dụng hệ điều hành này nói chung và dòng lệnh trên Linux nói riêng hiệu quả hơn. 1. Một số lưu ý quan trọng về Linux Terminal Để mở Terminal nhanh chóng từ GUI, nhấn tổ hợp phím Ctrl + Alt + T . Mổ xẻ hầu hết các lệnh Linux: [sudo] command [optional switch] [file or directory path] Sử dụng sudo sẽ chạy bất kỳ một lệnh nào đó dưới quyền Admin. Hầu hết các lệnh Linux dùng để cài đặt/gỡ bỏ các file hệ thống một chương trình, sử dụng nào đó để yêu cầu sudo. 2. Làm quen với tài khoản Các lệnh này sẽ giúp người dùng Linux mới làm quen với tài khoản Linux của mình. Lệnh Chức năng Ví dụ p...