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

本站现有博文309篇,共被浏览736025

本站已经建立2373天!

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