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

本站现有博文332篇,共被浏览882630

本站已经建立2587天!

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