首页 > 数据库 >云计算:LNMP网站架构,前期准备,安装php,安装MySQL

云计算:LNMP网站架构,前期准备,安装php,安装MySQL

时间:2024-08-30 19:51:55浏览次数:4  
标签:安装 mysql lnmp LNMP nginx yum MySQL php root

准备工作(初始化)

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

相关文章

  • 【Linux】开源的系统监控和故障排除工具Sysdig:用于系统监控、故障排除和安全审计,从下
    Sysdig是一个开源的系统监控和故障排除工具,可以捕获和分析系统调用,帮助你深入了解系统的运行状态。无论是开发人员、运维工程师还是安全专家,Sysdig都是进行系统监控、故障排除和安全审计的理想工具。本文将详细介绍Sysdig的安装、基本使用方法以及一些高级用法,并通过具......
  • docker安装和使用
    docker安装:sudoaptinstallapt-transport-httpsca-certificatescurlsoftware-properties-commonsudocurl-fsSLhttps://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg|sudogpg--dearmor-o/usr/share/keyrings/docker-archive-keyring.gpgecho"deb[arch=......
  • 【MySQL 11】索引 (带思维导图)
    文章目录......
  • 【MySQL 12】事务管理 (带思维导图)
    文章目录......
  • 【MySQL 14】用户管理
    文章目录......
  • 【MySQL 13】视图 (带思维导图)
    文章目录......
  • NSIS 脚本,安装时添加防火墙规则
    场景在Windows上运行需要访问网络或者提供网络服务的程序,需要防火墙放行。默认情况下,在首次运行程序时,可能会有如下弹窗,只有用户点击运行才能继续使用网络。部分情况,可能是直接被拦截,都没有这个提示。Windows防火墙规则|MicrosoftLearn如果出现问题,手动处理的话,可以在W......
  • Amos百度云下载与安装 附图文安装教程
    如大家所了解的,Amos是一款经常被运用在社会科学研究中的数据分析软件,尤其广泛用于人文社会科学领域的各种研究中。运用Amos,可以帮助研究人员使用结构方程模型(SEM)对他们收集到的数据进行分析与解释。自用Amos24安装包,可按需获取:https://pan.baidu.com/s/1lBYhFAqNXDWv6p......
  • 解决 Electron 安装失败问题的实用指南
    遇到安装失败问题?在国内或其他网络受限的环境中,安装Electron时可能会遇到各种错误。以下是一些解决这些问题的有效方法。如果您在Electron-Egg安装过程中遇到安装npm包报错的问题,也可以尝试以上办法,然后重新进行npmi--force操作重新安装包方法一:更改npm源这个方法在大......
  • docker-compose安装
    docker-compose离线安装版本对应docker-compose1.x对应dockerengine1.12及以上docker-compose2.x对应dockerengine20.10.0及以上下载2.25版本的只有2.20版本以上支持include特性sudocurl-L"https://github.com/docker/compose/releases/download/v2.25.0/docker......