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

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

本站已经建立2673天!

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