Linux基础35 搭建博客,搭建知乎,搭建edusoho

发布时间 2023-08-18 20:27:03作者: 战斗小人

5.搭建博客wordpress

1)上传包

https://cn.wordpress.org/下载 wordpress-5.0.3-zh_CN.tar.gz

[root@web01 ~]# cd /code/
[root@web01 code]# rz wordpress-5.0.3-zh_CN.tar.gz 

2) 解压代码包

[root@web01 code]# tar xf wordpress-5.0.3-zh_CN.tar.gz

3) 授权目录

[root@web01 code]# chown -R www.www /code/

4) 配置nginx

[root@web01 conf.d]# vim wordpress.conf
---------------------------------------
server {
    listen 80;
    server_name blog.linux.com;
    
    location / {
        root /code/wordpress;
        index index.php;
    }
    
    location ~* \.php$ {
        root /code/wordpress;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

[root@web01 conf.d]# systemctl restart nginx

# 修改win10 host文件
C:\Windows\System32\drivers\etc\hosts
10.0.0.7 blog.linux.com

5) 创建数据库

在数据库中添加一个库

[root@web01 conf.d]# mysql -uroot -padmin123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wordpress          |
+--------------------+
5 rows in set (0.01 sec)

 出现下图,表示成功

 登录

 博客搭建完成

 注: 插入图片,可能出现图片过大,通过改修改

[root@web01 ~]# vim /etc/php.ini
---------------------------------
post_max_size
upload_max_filesize

可以修改主题,网页上传 或者 手动下载主题,解压,赋权chown -R www.www 主题文件夹

 

6.搭建知乎wecenter

下载 https://github.com/wecenter/wecenter

1) 上传代码包

[root@web01 code]# rz WeCenter_3-2-1.zip
[root@web01 code]# unzip WeCenter_3-2-1.zip
[root@web01 code]# mv WeCenter_3-2-1 wecenter
[root@web01 code]# chown -R www.www ./*

2) 配置nginx

[root@web01 conf.d]# cp wordpress.conf zh.conf
[root@web01 conf.d]# vim zh.conf
---------------------------------------------
server {
    listen 80;
    server_name zh.linux.com;

    location / {
        root /code/wecenter;
        index index.php;
    }

    location ~* \.php$ {
        root /code/wecenter;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
------------------------------------------
# 改完重启
[root@web01 conf.d]# systemctl restart nginx

# 修改win10 host文件
C:\Windows\System32\drivers\etc\hosts
10.0.0.7 blog.linux.com zh.linux.com

3) 创建数据库

MariaDB [(none)]> create database zh;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wordpress          |
| zh                 |
+--------------------+
6 rows in set (0.01 sec)

 安装成功

 

7. 搭建edusoho

1)上传代码包

从官网下载

[root@web01 code]# rz edusoho-8.3.36.tar.gz 

2) 解压代码包

[root@web01 code]# tar xf edusoho-8.3.36.tar.gz 
[root@web01 code]# chown -R www.www edusoho 

3) 配置nginx

[root@web01 conf.d]# vim edu.conf
----------------------------------
server {
    listen 80;
    server_name edu.linux.com;
    root /code/edusoho/web;
    client_max_body_size 200m;
    
    location / {
        index app.php;
        try_files $uri @rewriteapp;
    }
    location @rewriteapp {
        rewrite ^(.*)$ /app.php/$1 last;
    }
    location ~ ^/udisk {
        internal;
        root /var/www/edusoho/app/data/;
    }
    location ~ ^/(app|app_dev)\.php(/|$) {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
        fastcgi_param HTTP_X-Sendfile-Type X-Accel-Redirect;
        fastcgi_param HTTP_X-Accel-Mapping /udisk=/code/edusoho/app/data/udisk;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 8 128k;
    }
    # 配置设置图片格式文件
    location ~* \.(jpg|jpeg|gif|png|ico|swf)$ {
        # 过期时间为3年
        expires 3y;
        # 关闭日志记录
        access_log off;
        # 关闭gzip压缩,减少CPU消耗,因为图片的压缩率不高。
        gzip off;
    }
    # 配置css/js文件
    location ~* \.(css|js)$ {
        access_log off;
        expires 3y;
    }
    # 禁止用户上传目录下所有.php文件的访问,提高安全性    
    location ~ ^/files/.*\.(php|php5)$ {
        deny all;
    }
    # 以下配置允许运行.php的程序,方便于其他第三方系统的集成。
    location ~ \.php$ {
        # [改] 请根据实际php-fpm运行的方式修改
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
    }
}

[root@web01 conf.d]# systemctl restart nginx

4) 优化参数

[root@web01 code]# vim /etc/php.ini
post_max_size = 200M
upload_max_filesize = 200M

[root@web01 conf.d]# systemctl restart php-fpm

注意:如果安装中,文件目录权限检查有问题,就创建赋权

# edusoho设置管理账号密码
用户 admin
密码 123456