加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

CentOS上yum方式安装配置LNMP

发布时间:2020-12-13 14:16:43 所属栏目:Linux 来源:网络整理
导读:h2 id="实验环境"实验环境 一台最小化安装的CentOS 7.3虚拟机 yum install -y epel-*yum install -y nginx mariadb-server php php-mysql php-fpm php-pdo php-pdo_dblib php-gd php-pear php-xml php-pecl-zip php-json php-devel wget vim nginx 的web主

<h2 id="实验环境">实验环境

  1. 一台最小化安装的CentOS 7.3虚拟机

yum install -y epel-*
yum install -y nginx mariadb-server php php-mysql 
php-fpm php-pdo php-pdo_dblib php-gd php-pear 
php-xml php-pecl-zip php-json php-devel wget vim

nginx的web主目录

mkdir /var/wwwroot
cd /var/wwwroot
echo -e hello_world >> index.html
echo -e "" >> info.php

nginx的配置文件

vim /etc/nginx/nginx.conf

nginx主目录和索引

  1. http下的server下的root的值修改为/var/wwwroot
  2. http下的server下添加index index.php index.html index.htm

http下的server区块加入以下内容

    location ~ .php$ {
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }

nginx和php-fpm

systemctl start nginx php-fpm
systemctl enable nginx php-fpm

setenforce 0
systemctl stop firewalld
systemctl disable firewalld

访问http://[centos_ip]/info.php

MySQL

systemctl start mariadb
systemctl enable mariadb

MySQL

mysql_secure_installation

Enter current password for root (enter for none):

敲击回车

Set root password? [Y/n]

Y,随后设置密码

Remove anonymous users?

意思为是否删除匿名用户

Disallow root login remotely?

意思为远程禁止root登录吗?

Remove test database and access to it?

意思为删除测试数据库吗?

Reload privilege tables now?

意思为现在重新加载特权表吗?

mysql -uroot -p

cd /var/wwwroot
rm -rf index.html
rm -rf info.php
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
cp -rf /var/wwwroot/wordpress/* /var/wwwroot
cd /var/wwwroot
rm -rf wordpress
chmod -R 777 *

mysql -uroot -p
CREATE DATABASE wordpress;

访问http://[centos_ip]/ 按提示安装即可

本文链接:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读