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

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

本站已经建立2628天!

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