准备工作(初始化)
1.关闭防火墙
systemctl disable firewalld --now //直接永久关闭防火墙
2.关闭SELINUX
查看SELINUX:getenforce
永久关闭:
[root@localhost ~]# vim /etc/selinux/config
SELINUX=enforcing|disabled
或者
[root@localhost ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
3.修改主机名
root@localhost ~]#hostnamectl set-hostname lnmp
4.安装本地yum源
root@localhost ~]#curl -o tool.sh 10.35.156.250/repo/tools.sh
root@localhost ~]#sh tool.sh
5.重启服务器
root@localhost ~]#reboot
安装nginx
[root@lnmp ~]#yum -y install nginx
[root@lnmp ~]#nginx // 启动
[root@lnmp ~]#ss -nplt //查看
[root@lnmp ~]# ss -nplt
#写一个测试页面
[root@lnmp ~]# rm -rf /usr/share/nginx/html/*
[root@lnmp ~]# echo "hello nginx" >/usr/share/nginx/html/index.html
[root@lnmp ~]# curl 127.0.0.1
安装php
[root@lnmp ~]# yum -y install php74-php-xsl php74-php php74-php-cli php74-php-devel php74-php-gd php74-php-pdo php74-php-mysql php74-php-fpm
启动php74-php-fpm
[root@lnmp ~]#systemctl start php74-php-fpm
查看启动状态
[root@lnmp ~]# ss -nplt | grep 9000
安装MySQL
清理环境
systemctl stop mysqld
yum -y remove `rpm -qa | grep mysql-community`
rm -rf /etc/my.*; rm -rf /var/log/musqld.log ;rm -rf /var/lib/mysql/
通过官方yum源安装
访问MySQL官网获取yum源(www.mysql.com)
下载并安装yum源
[root@lnmp ~]# yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@lnmp ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@lnmp ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@lnmp ~]# yum -y install mysql84-community-release-el7-1.noarch.rpm
安装MySQL
[root@lnmp ~]# yum -y install mysql-community-server --disablerepo mysql180-community-server --enablerepo musql157-community-server
通过本地yum源安装MySQL
[root@lnmp ~]# yum -y install mysql-server
启动MySQL实例
[root@lnmp ~]# systemctl start mysqld
获取临时密码
[root@lnmp ~]# grep "password " | /var/log/mysqld.log
或者
[root@lnmp ~]# awk '/A temporary password/{p=$NF}END{print p}' /var/log/mysqld.log
修改密码
[root@lnmp ~]# mysqladmin -uroot -p"`awk '/A temporary password/{p=$NF}END{print p}' /var/log/mysqld.log`" password "123qf456@"
或者
[root@lnmp ~]# mysqladmin -p "临时密码" password 123qf456@
登录数据库
[root@lnmp ~]#mysql -uroot -p123qf456@
创建数据库
mysql > create database wordpress(数据库名字 ) charset 'utf8';
mysql> \q
数据库安装完成后,在系统中生成的文件
1.配置文件
/etc/my.cnf //配置文件修改完一定要重启
2.日志文件
/var/log/mysql.log
3.数据目录
/var/lib/mysql/
nginx关联PHP
vim /etc/nginx/nginx.conf
//42行后加入以下内容
index index.php index.html index.htm;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
}[root@lnmp]#nginx -s reload //修改配置文件重启
[root@lnmp]# vim /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
# 浏览器访问
http://192.168.199.136
发布wordpress
1、上传wordpress压缩包
rz
2、解压缩
tar -xf wordpress-6.2.2-zh_CN.tar.gz
3、拷贝至nginx根目录下
cp -r wordpress/* /usr/share/nginx/html/
4、修改权限
chown -R nginx.nginx /usr/share/nginx/html/
chmod -R 777 /usr/share/nginx/html/
5、浏览器安装
最后添加一个命令,寻找目录或文件所在位置,很实用
[root@lnmp opt]# find / -name php.ini
/etc/opt/remi/php74/php.ini
标签:安装,mysql,lnmp,LNMP,nginx,yum,MySQL,php,root From: https://blog.csdn.net/weixin_63223249/article/details/141688492