LNMP是指Linux系统下,由Nginx + MySQL/MariaDB + PHP组成的网站服务器架构。以下是搭建LNMP环境的相关信息:
yum -y update
。yum install epel-release -y
。yum search nginx
。vim /etc/yum.repos.d/nginx.repo
,添加以下内容:[nginx]
name=nginx
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
yum install nginx -y
。systemctl start nginx
。systemctl enable nginx
。yum -y remove mariadb*
。vim /etc/yum.repos.d/MariaDB.repo
,添加MariaDB的软件库信息。yum install mariadb-server mariadb -y
。systemctl start mariadb
。systemctl enable mariadb
。yum install php php-fpm -y
。/etc/php.ini
,将cgi.fix_pathinfo=1
改为cgi.fix_pathinfo=0
。systemctl start php-fpm
。systemctl enable php-fpm
。/etc/nginx/nginx.conf
,在http
块中添加以下内容:location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
systemctl restart nginx
。nginx -t
。tail -f /var/log/nginx/error.log
。php-fpm -t
。tail -f /var/log/php-fpm/error.log
。以上是搭建LNMP环境的基本步骤以及常见问题的解决方法。如果在搭建过程中遇到其他问题,可以参考官方文档或相关社区论坛寻求帮助。