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

本站现有博文340篇,共被浏览1019278次

本站已经建立2719天!

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