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

本站现有博文323篇,共被浏览795329

本站已经建立2493天!

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