溫馨提示×

如何配置centos lnmp的虛擬主機

小樊
54
2025-08-16 21:30:37
欄目: 云計算

配置CentOS LNMP虛擬主機有使用命令和手動配置兩種方法,以下為你分別介紹:

使用命令配置

  1. 安裝LNMP:使用wget命令下載LNMP一鍵安裝包,然后解壓并執行安裝腳本,如wget http://soft.vpser.net/lnmp/lnmp1.9.tar.gz -cO lnmp1.9.tar.gz && tar zxf lnmp1.9.tar.gz && cd lnmp1.9 && ./install.sh lnmp。
  2. 添加虛擬主機:安裝完成后,執行lnmp vhost add命令,按提示輸入域名、網站目錄、是否啟用偽靜態、日志等信息。

手動配置

  1. 創建網站根目錄:如mkdir -p /home/wwwroot/虛擬主機域名。
  2. 創建虛擬主機配置文件:在/usr/local/nginx/conf/vhost/目錄下創建以域名命名的.conf文件,如vi /usr/local/nginx/conf/vhost/example.com.conf。
  3. 編輯配置文件:在文件中添加如下內容:
server {
    listen 80;
    server_name example.com;
    root /home/wwwroot/example.com;
    index index.html index.htm index.php;
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}
  1. 重啟Nginx:執行systemctl restart nginx使配置生效。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女