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

本站现有博文333篇,共被浏览922024

本站已经建立2628天!

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