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

本站现有博文323篇,共被浏览801792

本站已经建立2501天!

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