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

本站现有博文312篇,共被浏览744620

本站已经建立2388天!

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