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

本站现有博文340篇,共被浏览1016804次

本站已经建立2718天!

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