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

本站现有博文322篇,共被浏览784451

本站已经建立2478天!

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