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

本站现有博文327篇,共被浏览833575

本站已经建立2538天!

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