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

本站现有博文327篇,共被浏览833368

本站已经建立2538天!

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