LNMP 的相关配置

一、LNMP 的总体布局

(博客系统)一组常用来搭建动态网站或者服务器的开源软件
L:linux
N:nginx(反向代理)代理地址
M:mysql(数据库)
P:php(连接数据和网站)

1、安装LNMP的前提

(Yum 和 IP)详情请看 Linux的基础操作

1)有client(客户机)、server(服务机)     客户机测试,可以用Windows
2)client(客户机)、server(服务机)都配置好 同一网段的网络		
3)server(服务机)配置yum源
4)(lnmp),(wordpress-4.7.3-zh_CN.zip)把这两个文件下载到root目录里

2、修改主机名,增加一个yum仓库

[root@localhost ~]# hostnamectl set-hostname lnmp
[root@localhost ~]# bash

[root@lnmp ~]# vim /etc/yum.repos.d/local.repo
	[lnmp]
	name=lnmp
	baseurl=file:///root/lnmp/lnmp
	enable=1
	gpgcheck=0

3、安装 nginx, mysql, php

[root@lnmp ~]# yum -y install nginx  mariadb-server  php  php-mysql  php-fpm

二、nginx 的配置 并 重启服务

[root@lnmp ~]# vim /etc/nginx/conf.d/default.conf
	  末行模式
	  set nu  显示行号
	  
	  30-36行注释去掉
10行  index  index.php  index.html index.htm;    #这行加个index.php  
31行  root /user/share/nginx/html				 #把html改成/usr/share/nginx/html

34行  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;   #改/scripts为$document_root

[root@lnmp ~]# systemctl start nginx			 #重启nginx服务
[root@lnmp ~]# systemctl enable nginx

三、配置数据库,创wordpress库

初始化数据库

[root@lnmp ~]# systemctl start mariadb			#必须先启动数据库才能初始化
[root@lnmp ~]# systemctl enable mariadb

[root@lnmp ~]# mysql_secure_installation		#初始化
这里(y,y,n,y,y)		记住这里输入的数据库密码

[root@lnmp ~]# mysql -uroot -p000000
->  create  database  wordpress;				#所有的数据都在这个库里
->  show databases;
->  exit
[root@lnmp ~]# systemctl restart mariadb	

四、配置php,解压wordpress-4.7.3-zh_CN.zip

[root@lnmp ~]#unzip wordpress-4.7.3-zh_CN.zip
[root@lnmp ~]# cd wordpress
[root@lnmp ~]# cp -ar * /usr/share/nginx/html/		#把所有的内容拷贝到LNMP的网站存放路径

[root@lnmp ~]# cd  /usr/share/nginx/html/
[root@lnmp ~]# chmod  -R 777 ./						#设置文件权限

[root@lnmp ~]# systemctl start php-fpm
[root@lnmp ~]# systemctl enable php-fpm				#重启php服务

五、查看端口并访问

[root@lnmp ~]# systemctl stop firewalld.service 	#关闭防火墙
[root@lnmp ~]# systemctl disable firewalld.service 	

[root@lnmp ~]# setenforce 0			#关闭Selinux 

[root@lnmp ~]# netstat -pant				#查看端口
	3306:mysqld
	9000:php-fpm
	80:nginx

[root@lnmp ~]# firefox http://192.168.200.10   #火狐访问
posted @ 2021-12-21 13:38  陽YANG  阅读(67)  评论(0编辑  收藏  举报