05-LNMP搭建WordPress、wecenter知乎和edusoho网校

1、部署博客产品Wordpress

(1)对Wordpress创建Nginx配置文件
[root@Server-1 ~]# cat /etc/nginx/conf.d/wordpress.zxc.com.conf 
server {
 listen 80;
 server_name wordpress.zxc.com;
 root /code/wordpress;

 location / {
  index index.php index.html;
 }

 location ~ .php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
 }
}
(2)根据nginx中定义的内容,创建站点目录并且进行授权
[root@Server-1 ~]# mkdir /code/wordpress
[root@Server-1 code]# wget -c https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@Server-1 code]# tar -xzf latest-zh_CN.tar.gz
(3)修改nginx与php-fpm的运行用户为www,并授权代码属主和属组都为www
#注意:如果没有该用户,启动一定会报错
[root@Server-1 code]# groupadd -g 666 www
[root@Server-1 code]# useradd -u666 -g666 www

#修改nginx与php-fpm管理进程,的运行身份为www
[root@Server-1 code]# sed -i '/^user /c user  www;' /etc/nginx/nginx.conf
[root@Server-1 code]# sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf 
[root@Server-1 code]# sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf

#一定要重启才生效
[root@Server-1 code]# systemctl restart nginx
[root@Server-1 code]# systemctl restart php-fpm

#最后授权代码为www
[root@Server-1 code]# chown -R www.www /code/wordpress
(4)创建一个wordpress库
[root@Server-1 ~]# mysql -uroot -pP@ssw0rd
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)
#注:访问wordpress.zxc.com,根据提示进行填写参数信息

2、解决Nginx和php上传或下载文件大小限制

#调整nginx的上传大小,建议加在server下
client_max_body_size 100m;     #默认nginx仅支持上传1m大小的文件
[root@Server-1 code]# systemctl restart nginx

#调整php的上传大小
[root@Server-1 ~]# vim /etc/php.ini
post_max_size = 200M
upload_max_filesize = 200M

3、部署wecenter知乎

(1)对wecenter创建Nginx配置文件
[root@Server-1 ~]# cat /etc/nginx/conf.d/wecenter.zxc.com.conf 
server {
 listen 80;
 server_name wecenter.zxc.com;
 root /code/wecenter;

 location / {
  index index.php index.html;
 }

 location ~ .php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
 }
}
(2)根据nginx中定义的内容,创建站点目录并且进行授权
#在该网站下载wecenter     https://wenda.wecenter.com/timeline/
[root@Server-1 ~]# mkdir /code/wecenter
[root@Server-1 code]# unzip -d wecenter wecenter3.6.2.zip
(3)授权代码属主和属组都为www
#最后授权代码为www
[root@Server-1 code]# chown -R www.www /code/wecenter
(4)创建一个wecenter库
[root@Server-1 ~]# mysql -uroot -pP@ssw0rd
MariaDB [(none)]> create database wecenter;
Query OK, 1 row affected (0.00 sec)

#查询该台数据库服务有多少个库
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
test               |
| wordpress          | 
| wecenter           |
+--------------------+
5 rows in set (0.01 sec)
#注:访问 wecenter.zxc.com,根据提示进行填写参数信息

4、部署edusoho网校

(1)对edusoho创建Nginx配置文件
[root@Server-1 ~]# cat /etc/nginx/conf.d/edu.zxc.com.conf
server {
    listen 80;
    server_name edu.zxc.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 /code/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$ {
        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;
    }
}
(2)根据nginx中定义的内容,创建站点目录并且进行授权
[root@Server-1 ~]# mkdir /code/edusoho
[root@Server-1 code]# wget -c http://download.edusoho.com/edusoho-22.1.4.zip
[root@Server-1 code]# unzip -d edusoho edusoho-22.1.4.zip
(3)授权代码属主和属组都为www
#最后授权代码为www
[root@Server-1 code]# chown -R www.www edusoho
(4)创建一个edusoho库
[root@Server-1 ~]# mysql -uroot -pP@ssw0rd
MariaDB [(none)]> create database edusoho;
Query OK, 1 row affected (0.00 sec)

#查询该台数据库服务有多少个库
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
test               |
| wordpress          | 
| wecenter           |
| edusoho            |
+--------------------+
5 rows in set (0.01 sec)
#注:访问 edu.zxc.com,根据提示进行填写参数信息


原文始发于微信公众号(运维库):05-LNMP搭建Wordpress、wecenter知乎和edusoho网校

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/64317.html

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!