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

本站现有博文321篇,共被浏览773234

本站已经建立2462天!

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