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

本站现有博文329篇,共被浏览858662

本站已经建立2567天!

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