Linux7.9安装LNMP

1、安装MariaDB/MySQL
 
CentOS/RHEL7使用了MariaDB替代了默认的MySQL。作为MySQL的简单替代品,MariaDB保证了与MySQL的API和命令行用法方面最大的兼容性。下面是关于怎么在 CentOS7上安装和配置MaraDB/MySQL的操作示例。
 
yum install mariadb-server
systemctl start mariadb
systemctl enable mariadb
 
在成功启动MariaDB/MySQL服务后,还要进行数据库的安全配置,如设置(非空)的root密码、删除匿名用户、锁定远程访问。执行如下代码:
mysql_secure_installation
根据提示设置root密码,以及删除匿名用户等操作

  

2安装PHP7.2

#查询是否安装过php
yum list installed | grep php
yum provides php

#下载源
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
     
yum install php72w php72w-opcache php72w-xml php72w-gd php72w-devel php72w-mysql php72w-intl php72w-mbstring php72w-fpm php72w-cli php72w-mbstring php72w-pdo php-redis
     
php -v
#PHP 7.2.14
     
#设置时区
vim /etc/php.ini
date.timezone = "Asia/Shanghai"


 #设置php-fpm运行用户组
vim /etc/php-fpm.d/www.conf
user  = nginx
group = nginx
listen.owner = nobody      前面;去掉
listen.group = nobody      前面;去掉
listen.mode = 0660         前面;去掉
     
#启动php-fpm
systemctl start php-fpm.service
systemctl status php-fpm.service
systemctl stop php-fpm.service
systemctl restart php-fpm.service
#设置开机自启动
systemctl enable php-fpm.service

  

#安装mcrypt扩展
    #mcrypt扩展从php7.1.0开始废弃,自php7.2.0起会移到pecl
    #http://pecl.php.net/package/mcrypt
    yum install gcc libmcrypt libmcrypt-devel mcrypt mhash
    wget  http://pecl.php.net/get/mcrypt-1.0.1.tgz
    tar -zxvf mcrypt-1.0.1.tgz
    cd mcrypt-1.0.1
     
    #whereis phpize
    /usr/bin/phpize
    #whereis php-config
    ./configure --with-php-config=/usr/bin/php-config && make && make install
     
    #vim php.ini
    extension=mcrypt.so
     
    #重启php-fpm
    systemctl restart php-fpm.service

  

3、nginx安装
    yum install nginx
    #http 对象中修改
    #log_format 前的#去掉
    #添加 client_max_body_size    200m;
    #添加 include /usr/local/nginx/conf/conf.d/*.conf;
    #项目的http配置文件可以放到conf.d文件夹中了
     
    #设置开机自启动
    systemctl enable nginx.service

  

4、redis安装
    yum install redis
     
    #启动redis
    systemctl start redis.service
    systemctl status redis.service
    systemctl stop redis.service
    systemctl restart redis.service
    #设置开机自启动
    systemctl enable redis.service

  

posted on 2023-08-21 17:47  loveking_阳  阅读(41)  评论(0编辑  收藏  举报

导航