EADST

Hosting a Static Website with Nginx on Ubuntu

If you have a folder containing an index.html file along with supporting assets like CSS, fonts, JS, and images, you can easily serve it using Nginx and access it via a domain like xiedong.me.

Here’s a simple step-by-step guide to get it done.

📁 Step 1: Organize Your Website Files

Place your website files in a directory, such as:

/var/www/xiedong

Make sure it contains:

/var/www/xiedong/
├── index.html
├── css/
├── js/
├── fonts/
└── images/

⚙️ Step 2: Configure Nginx

Edit your Nginx configuration file, e.g., /etc/nginx/conf.d/me.conf:

server {
    listen 80;
    server_name xiedong.me www.xiedong.me;

    root /var/www/xiedong;
    index index.html;

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

This tells Nginx to serve files from the /var/www/xiedong directory and to display index.html by default.

🔐 Step 3: Set Permissions

Ensure the Nginx user (usually www-data) can read the files:

sudo chown -R www-data:www-data /var/www/xiedong
sudo chmod -R 755 /var/www/xiedong

🚀 Step 4: Test and Restart Nginx

Test your Nginx configuration:

sudo nginx -t

If there are no errors, restart Nginx:

sudo systemctl restart nginx

🌐 Step 5: Access Your Site

Now, navigate to:

http://xiedong.me

You should see your website live!

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Crawler Harness Random Domain ms-swift Tiktoken git-lfs Shortcut Pillow VGG-16 多进程 Firewall Paddle SPIE Ptyhon TensorRT 论文 SQLite Jev 强化学习 BTC Template Base64 scipy SVR Rebuttal Sklearn Nginx Vmess transformers ResNet-50 RAR Streamlit Claude EXCEL tar Qwen BF16 Diagram API Quantization OCR FastAPI 财报 Permission TTS GPT4 报税 Mixtral LoRA GoogLeNet Disk AI GPTQ Knowledge XML Python FlashAttention Augmentation 飞书 Food CEIR Attention CUDA Bitcoin Data Transformers CV PyCharm XGBoost Quantize 第一性原理 Ubuntu LLM InvalidArgumentError Anaconda v2ray WebCrawler v0.dev Password HuggingFace Jetson API网关 Heatmap 递归学习法 音频 Google Algorithm Hotel 继承 llama.cpp 多线程 CC 阿里云 WAN Qwen2.5 证件照 Statistics HaggingFace Pickle icon Pandas UI 域名 Gemma Breakpoint Proxy diffusers uwsgi logger Image2Text Magnet mmap MD5 GGML Animate Git Cloudreve LeetCode VSCode UNIX Review Zip ChatGPT YOLO DeepSeek PDF RGB 版权 DeepStream Linux FP8 BeautifulSoup CSV Logo hf Web Bipartite Freesound Land Paper LLAMA tqdm RL Excel 关于博主 OpenCV Interview Agent FP64 Plotly Distillation NLP Qwen2 git 公式 Datetime 搞笑 净利润 CAM 论文速读 printf 顶会 算法题 TSV SQL Conda CLAP Use Search Bin PyTorch ModelScope Jupyter 图标 NLTK SAM Safetensors 腾讯云 CTC Llama uWSGI Github Michelin Clash Miniforge Math ONNX Input Numpy Windows Hungarian PIP Translation Video torchinfo PDB Django QWEN News Card Baidu IndexTTS2 OpenAI JSON Bert LaTeX Hilton Plate C++ Website Color 图形思考法 Dataset Pytorch TensorFlow NameSilo 签证 Tensor Markdown 云服务器 COCO VPN Docker Vim GIT Tracking FP16 FP32
站点统计

本站现有博文337篇,共被浏览957763次

本站已经建立2669天!

热门文章
文章归档
回到顶部