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

本站现有博文321篇,共被浏览763963

本站已经建立2440天!

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