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

本站现有博文332篇,共被浏览875813

本站已经建立2583天!

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