以下是在CentOS上配置LNMP虚拟主机的步骤:
可以使用一键安装包或手动安装。以下以CentOS 7为例介绍一键安装:
wget -c http://soft.vpser.net/lnmp/lnmp0.5.tar.gz
。tar zxvf lnmp0.5.tar.gz
。cd lnmp0.5/
,然后执行./centos.sh
,按提示输入域名、MySQL root密码等信息。/home/wwwroot/yourdomain.com
。/usr/local/nginx/conf/vhost/
下创建yourdomain.com.conf
,内容示例:server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /home/wwwroot/yourdomain.com;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass unix:/tmp/php-cgi.sock;
}
}
/etc/init.d/nginx restart
或systemctl restart nginx
。