centos

centos lnmp虚拟主机配置

小樊
49
2025-09-03 23:52:41
栏目: 云计算

以下是在CentOS上配置LNMP虚拟主机的步骤:

环境准备

更新系统:sudo yum update -y。安装Nginx、MySQL、PHP等基础软件,可参考中方法,如使用yum install -y nginx mariadb-server php php-fpm等命令。

配置虚拟主机

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 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
    access_log /home/wwwlogs/example.com.log;
}

修改后需重启Nginx服务使配置生效:sudo systemctl restart nginx

0
看了该问题的人还看了