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

本站现有博文338篇,共被浏览977916次

本站已经建立2690天!

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