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

本站现有博文333篇,共被浏览909486

本站已经建立2612天!

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