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

本站现有博文320篇,共被浏览755771

本站已经建立2418天!

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