在Linux系统下配置LNMP(Linux, Nginx, MySQL, PHP)环境通常涉及以下步骤:
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo yum install mysql-server -y
sudo systemctl start mysqld
sudo mysql_secure_installation
sudo chkconfig mysqld on
sudo yum install php php-mysql php-fpm php-xml php-zip php-curl php-gd -y
sudo systemctl restart nginx
/etc/nginx/sites-available/default
:sudo nano /etc/nginx/sites-available/default
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;
}
fastcgi_pass
指向正确的PHP-FPM套接字文件。/etc/php-fpm.d/www.conf
:sudo nano /etc/php-fpm.d/www.conf
user
和group
设置为nginx
,以便Nginx可以正确处理PHP文件:user = nginx
group = nginx
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
info.php
的文件,并添加以下内容:<?php
phpinfo();
?>
/info.php
,如果能够看到PHP的信息页面,说明LNMP环境已经搭建成功。以上步骤是在CentOS系统下配置LNMP环境的基本流程。对于Ubuntu系统,命令会有所不同,例如使用apt-get
代替yum
来安装软件包。此外,具体的版本号和路径可能会根据不同的Linux发行版和软件版本有所变化,因此在实际操作中需要根据最新的官方文档或指南进行调整。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:如何在LNMP中配置PHPMyAdmin