全国职业院校技能大赛-云计算赛项

本文详细描述了如何在CentOS7.9系统上分别构建LNMP(Nginx、MySQL、PHP)和LAMP(Apache、MySQL、PHP)环境,包括安装步骤、配置和权限设置,以及WordPress的部署过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、LNMP环境搭建

1、centos7.9

自行准备linux环境,笔者使用的是centos7.9.2009
查看版本命令为:
cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
[root@blog ~]# setenforce 0
[root@blog ~]# hostnamectl set-hostname blog
[root@blog ~]# curl -O http://10.24.2.208/Application/wp-lnmp-c7.9.tar.gz
[root@blog ~]#  tar xf wp-lnmp-c7.9.tar.gz 
[root@blog ~]# rm -rf /etc/yum.repos.d/CentOS-*
[root@blog ~]# cat /etc/yum.repos.d/local.repo
[wordpress]
name=wordpress
baseurl=file:///root/wp-lnmp-c7.9/packages/
gpgcheck=0
enabled=1
[root@blog ~]# yum install -y unzip

2、nginx

[root@blog ~]# yum install -y nginx
[root@blog ~]# vi /etc/nginx/nginx.conf.default
        location / {
            root   html;
            index index.php index.html index.htm;
        }
​
      location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
[root@blog ~]# vi /etc/nginx/nginx.conf
    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;
​
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
    location / {   
        root   html;
        index index.php  index.html index.htm;         #localtion 加入这个解析 
    }
        error_page 404 /404.html;
        location = /404.html {
        }
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;    #加入php解析
            include        fastcgi_params;
        }
​
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
    }

3、mariadb

[root@blog ~]# yum install -y mariadb mariadb-server
[root@blog ~]# systemctl start mariadb 
[root@blog ~]# mysqladmin -uroot password '123456'
[root@blog ~]# mysql -uroot -p123456 -e "create database wordpress;"
[root@blog ~]# mysql -uroot -p123456
MariaDB [(none)]> grant all on *.* to root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.000 sec)
​
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

4、php

[root@blog ~]# yum install -y php*
[root@blog ~]# systemctl start php-fpm

5、wordpress

[root@blog ~]# unzip wp-lnmp-c7.9/wordpress-4.7.3-zh_CN.zip
[root@blog ~]# rm -rf /usr/share/nginx/html/*
[root@blog ~]# cp -rvf wordpress/* /usr/share/nginx/html/
[root@blog ~]# systemctl restart nginx php-fpm
[root@blog ~]# chown nginx:nginx /usr/share/nginx/html/
[root@blog ~]# chown -R 755 /usr/share/nginx/html/

二、LAMP环境搭建

1、centos7.9

自行准备linux环境,笔者使用的是centos7.9.2009
查看版本命令为:
cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
[root@blog ~]# setenforce 0
[root@blog ~]# hostnamectl set-hostname blog
[root@blog ~]# curl -O http://10.24.2.208/Application/wp-lnmp-c7.9.tar.gz
[root@blog ~]#  tar xf wp-lnmp-c7.9.tar.gz 
[root@blog ~]# rm -rf /etc/yum.repos.d/CentOS-*
[root@blog ~]# cat /etc/yum.repos.d/local.repo
[wordpress]
name=wordpress
baseurl=file:///root/wp-lnmp-c7.9/packages/
gpgcheck=0
enabled=1
[root@blog ~]# yum install -y unzip

2、apache

[root@blog ~]# yum install -y httpd

3、mariadb

[root@blog ~]# yum install -y mariadb mariadb-server
[root@blog ~]# systemctl start mariadb 
[root@blog ~]# mysqladmin -uroot password '123456'
[root@blog ~]# mysql -uroot -p123456 -e "create database wordpress;"
[root@blog ~]# mysql -uroot -p123456
MariaDB [(none)]> grant all on *.* to root@'localhost' identified by '123456';
Query OK, 0 rows affected (0.000 sec)
​
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

4、php

[root@blog ~]# yum install -y php*

5、wordpress

[root@blog ~]# unzip wp-lnmp-c7.9/wordpress-4.7.3-zh_CN.zip
[root@blog ~]# rm -rf /var/www/html/*
[root@blog ~]# cp -rvf wordpress/* /var/www/html/
[root@blog ~]# chown apache:apache -R /var/www/html/
[root@blog ~]# chown 755  -R /var/www/html/
[root@blog ~]# systemctl start php-fpm httpd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a'ゞ过去已成回忆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值