一步一步带你设置LNMP环境
本文已参与「新人创作礼」活动,一起开启掘金创作之路。
LNMP是什么意思
Linux、Nginx、Mysql、PHP
linux系统
这个大家可以去阿里云或者腾讯云,再或者其他的一些服务器代理平台去购买
nginx安装
yum install nginx -y
mysql安装
yum install mysql-server -y
php安装
yum install php php-fpm php-mysql -y
以上就是LNMP的安装代码,安装好了,我们肯定还是需要将它们启动起来的,那么如何启动呢?
Nginx启动:nginx Nginx重载:service nginx restart
Mysql启动:service mysqld restart 设置 MySQL密码(默认账号:root):/usr/bin/mysqladmin -u root password '这里填写要设置的密码'
PHP启动:service php-fpm start 查看PHP监听端口:netstat -nlpt | grep php-fpm
当然可以将其添加到开启自启动里:
chkconfig nginx on,chkconfig mysqld on,chkconfig php-fpm on
以上就是启动代码,接下来我们要准备什么呢?
我们弄一个服务器肯定不会是只放一个网站吧,那样就太浪费了?
既然要放多个网站,那么是不是需要配置域名解析,并且要让我们配置的域名能够找到自己的运行目录?那我们要怎么操作呢?
我们需要先进入目录:
/etc/nginx/conf.d/
,然后创建文件test.com.conf
(命令:touch test.com.conf
) 然后打开test.com.conf
(命令vim test.com.conf
),填写下列代码,大家可以根据标注自行更改
server {
listen 80; #监听端口,可以使用:netstat -nlpt | grep nginx,来查看端口
server_name test.com; #这里是你要绑定的域名
index index.php index.html index.html; #这里是网站首页默认文件
root /www/web/test; #这里是你要绑定的程序目录,就是要运行的程序根目录
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000; #这里可以使用:netstat -nlpt | grep php-fpm,来查看端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
到了这一步服务器的配置环节已经完成了,接下来直接解析多个域名到我们的服务器ip上就完成了
是不是很简单呢?更多经验、知识,请持续关注我哈!
上一篇: 搞定Linux运维:LNMP全解析
推荐阅读
-
如何使用iOS平台上的Digilink加速器进行进一步设置
-
如何在LNMP环境下添加、移除虚拟主机并设置伪静态?详细教程在这里!
-
一步一步教你:在CentOS VPS上安装LNMP环境的图文教程
-
如何在服务器上设置LNMP环境?
-
周末必学!一步一步教你怎么搭建LNMP架构和部署系统,跟着Nginx系列教程走~
-
一步一步教你如何在CentOS 6.8上安装LNMP环境(包含Nginx、MySQL和PHP)
-
一步一步带你设置LNMP环境
-
在Ubuntu 20.04上设置LNMP环境的简单步骤
-
一步一步在Linux上设置LNMP环境来建立个人博客网站
-
在 CentOS 8 上设置 LNMP 环境的简易指南