网校及论坛系统搭建

1.安装httpd服务

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

[root@VM_0_11_centos ~]# systemctl start httpd

2.编辑虚拟主机配置文件【虚拟主机的配置文件: 指挥httpd这个服务怎么去工作】

[root@VM_0_11_centos ~]# cd /etc/httpd

[root@VM_0_11_centos httpd]# ls

conf 【存的是主配置文件】 conf.d【存的是虚拟主机配置文件】  conf.modules.d  logs  modules  run

[root@VM_0_11_centos httpd]# cd conf.d

[root@VM_0_11_centos conf.d]# vim wordpress.conf

写如下内容:
<VirtualHost *:80> #所有IP过来访问我的80都可以接受
        ServerName www.wordpress1.com #域名
        DocumentRoot /var/www/wordpress #网站主目录
</VirtualHost>


<Directory "/var/www/wordpress"> #对于目录的权限设置
        Require all granted

</Directory>


[root@VM_0_11_centos conf.d]# vim edusoho.conf

写如下内容:

使用末行模式:r wordpress.conf 【读取这个文件】

然后更改:% s/wordpress/edusoho/g 

:% s/1/2/g

注:这个edusoho很特殊,它的网页主目录是在/var/www/edusoho/web 下所以这里还要手动添加一下

[root@VM_0_11_centos conf.d]# httpd -t 【检查语法】

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message 【需要更改主配置的一律不管】
Syntax OK 【表示没问题】

 3.新建网站主目录

[root@VM_0_11_centos conf.d]# mkdir /var/www/wordpress

[root@VM_0_11_centos conf.d]# mkdir /var/www/edusoho  【edusoho这个文件本身带有web目录,所以不用自己创建】

[root@VM_0_11_centos conf.d]# systemctl restart httpd

4.添加一个测试

[root@VM_0_11_centos conf.d]# cd /var/www/wordpress
[root@VM_0_11_centos wordpress]# ls
[root@VM_0_11_centos wordpress]# echo "this is wordpress" >> index.html
[root@VM_0_11_centos wordpress]# ls
index.html
[root@VM_0_11_centos wordpress]# cat index.html
this is wordpress
[root@VM_0_11_centos wordpress]# cd /var/www/edusoho
[root@VM_0_11_centos web]# ls
[root@VM_0_11_centos web]# echo "this is edusoho" >> index.html
[root@VM_0_11_centos web]# ls
index.html
[root@VM_0_11_centos web]# cat index.html

this is edusoho

因为又对httpd服务进行了修改,所以要再重启一下httpd服务

[root@VM_0_11_centos web]# systemctl restart httpd

4.添加解析

在电脑C:\Windows\System32\drivers\etc 右键用记事本打开hosts在这个文件末行添加

服务器公网IP www.wordpress1.com【虚拟主机域名】

服务器公网IP www.edusoho2.com【虚拟主机域名】

保存

5.在浏览器输入www.wordpress1.com  显示网页主目录

www.edusoho2.com 显示网页主目录

6.部署数据库

[root@VM_0_11_centos web]# yum -y install mariadb-server mariadb

[root@VM_0_11_centos web]# systemctl start mariadb

[root@VM_0_11_centos web]# mysqladmin -uroot -p password "密码"

Enter password: 【回车】

[root@VM_0_11_centos web]# mysql -uroot -p

Enter password: 

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


MariaDB [(none)]> create database edusoho;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| edusoho            |
| mysql              |
| performance_schema |
| test               |
| wordpress          |
+--------------------+

6 rows in set (0.00 sec)

MariaDB [(none)]> exit

Bye

3.部署php环境

[root@VM_0_11_centos web]# yum -y install php php-cli php-curl【用于php去识别域名,php本身是用来沟通web服务和数据库的,识别浏览器发送过来的域名的】 php-fpm 【产生fast-cgi进程】php-intl php-mcrypt php-mysql php-gd php-mbstring php-xml php-dom gd  【共12个】

[root@VM_0_11_centos web]# systemctl start php-fpm 【启动服务,让其产生fast-cgi线程】

修改 PHP 配置文件【更改一些上传及内存的限制和时区,因为网校系统需要上传一些视频,默认值很小】

[root@VM_0_11_centos web]# vim /etc/php.ini

查找:

/post_max_size 【最大上传文件大小】8改为1024

/memory_limit   【php内存限制】128改为1024

/upload_max_filesize 【upload上传】2改为1024

/date.timezone 找到两处,在第二处填写 亚洲上海【注:时区只有上海,没有北京】

; http://php.net/date.timezone

;date.timezone = Asia/Shanghai

保存退出

[root@VM_0_11_centos web]# vim /etc/php-fpm.d/www.conf

查找:

/listen.owner 

 找到三行

;listen.owner = nobody
;listen.group = nobody

;listen.mode = 0666

这里需要去掉前面分号

这里介绍一个 vim 的一个高级应用:

停留在第一个要取消的分号上面【按 ctrl+v】【按向下方向键】把光标停留在最后一个需要删除的分号上面,【按d】

此时这三行开头的分号就都去掉了。

改为的最终形式:
listen.owner = apache 【这个apache用户在最初安装 httpd时就创建出来了】
listen.group = apache

listen.mode = 0666

保存退出

如何确定一个用户在系统中是否存在?

[root@VM_0_11_centos web]# id apache【用户名】
uid=48(apache) gid=48(apache) groups=48(apache)

[root@VM_0_11_centos web]# systemctl restart php-fpm 【重启,让php参数生效】

源码上线

[root@VM_0_11_centos web]# cd /root

[root@VM_0_11_centos web]# wget http://download.edusoho.com/edusoho-7.5.12.tar.gz 【下载edusoho】

[root@VM_0_11_centos ~]# ls
edusoho-7.5.12.tar.gz

[root@VM_0_11_centos ~]# tar xf edusoho-7.5.12.tar.gz 【解压】

[root@VM_0_11_centos ~]# ls

edusoho  edusoho-7.5.12.tar.gz

[root@VM_0_11_centos ~]# cp -rf edusoho/* /var/www/edusoho

[root@VM_0_11_centos web]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz

[root@VM_0_11_centos ~]# tar xf wordpress-4.9.4-zh_CN.tar.gz
[root@VM_0_11_centos ~]# ls

edusoho  edusoho-7.5.12.tar.gz  wordpress  wordpress-4.9.4-zh_CN.tar.gz

[root@VM_0_11_centos ~]# cd wordpress
[root@VM_0_11_centos wordpress]# ls
index.php        wp-blog-header.php    wp-includes        wp-settings.php
license.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.php
readme.html      wp-config-sample.php  wp-load.php        wp-trackback.php
wp-activate.php  wp-content            wp-login.php       xmlrpc.php

wp-admin         wp-cron.php           wp-mail.php


[root@VM_0_11_centos wordpress]# mv wp-config-sample.php wp-config.php


[root@VM_0_11_centos wordpress]# ls
index.php        wp-blog-header.php    wp-includes        wp-settings.php
license.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.php
readme.html      wp-config.php         wp-load.php        wp-trackback.php
wp-activate.php  wp-content            wp-login.php       xmlrpc.php

wp-admin         wp-cron.php           wp-mail.php

[root@VM_0_11_centos wordpress]# vim wp-config.php

找到这三行:
/** WordPress数据库的名称 */
define('DB_NAME', 'database_name_here');


/** MySQL数据库用户名 */
define('DB_USER', 'username_here');


/** MySQL数据库密码 */
define('DB_PASSWORD', 'password_here');

改为:
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');


/** MySQL数据库用户名 */
define('DB_USER', 'root');


/** MySQL数据库密码 */
define('DB_PASSWORD', '数据库密码');

保存退出

[root@VM_0_11_centos wordpress]# systemctl restart httpd mariadb php-fpm

[root@VM_0_11_centos wordpress]# cd /root
[root@VM_0_11_centos ~]# ls
edusoho  edusoho-7.5.12.tar.gz  wordpress  wordpress-4.9.4-zh_CN.tar.gz
[root@VM_0_11_centos ~]# cp -rf wordpress/* /var/www/wordpress

[root@VM_0_11_centos ~]# cd /var/www/wordpress
[root@VM_0_11_centos wordpress]# ls
index.html       wp-blog-header.php    wp-includes        wp-signup.php
index.php        wp-comments-post.php  wp-links-opml.php  wp-trackback.php
license.txt      wp-config.php         wp-load.php        xmlrpc.php
readme.html      wp-content            wp-login.php
wp-activate.php  wp-content.php        wp-mail.php
wp-admin         wp-cron.php           wp-settings.php
[root@VM_0_11_centos wordpress]# rm index.html

rm: remove regular file ‘index.html’? y

[root@VM_0_11_centos web]# systemctl restart httpd
[root@VM_0_11_centos web]# pwd
/var/www/edusoho
[root@VM_0_11_centos web]# ls
api  app  bootstrap  index.html  plugins  README.html  src  vendor  vendor_user  web
[root@VM_0_11_centos web]# ls
api  app  bootstrap  plugins  README.html  src  vendor  vendor_user  web

[root@VM_0_11_centos web]# chown -R apache:apache /var/www/edusoho/* 【-R表示所有的目录,所有的层级】

[root@VM_0_11_centos web]# systemctl restart httpd php-fpm【网页还是不能正常呈现】

[root@VM_0_11_centos web]# cd /root
[root@VM_0_11_centos ~]# ls
edusoho  edusoho-7.5.12.tar.gz  wordpress  wordpress-4.9.4-zh_CN.tar.gz
[root@VM_0_11_centos ~]# cd edusoho
[root@VM_0_11_centos edusoho]# ls
api  app  bootstrap  plugins  README.html  src  vendor  vendor_user  web
[root@VM_0_11_centos edusoho]# cd web
[root@VM_0_11_centos web]# ls
app_dev.php  assets   crossdomain.xml  favicon.ico  install     themes
app.php      bundles  customize        files        robots.txt
[root@VM_0_11_centos web]# ll
total 48
-rw-r--r--  1 501 games 2157 Mar 27  2017 app_dev.php
-rw-r--r--  1 501 games 1931 Mar 27  2017 app.php
drwxr-xr-x  8 501 games 4096 Jul  7 15:28 assets
drwxr-xr-x 14 501 games 4096 Jul  7 15:28 bundles
-rw-r--r--  1 501 games  323 Mar 27  2017 crossdomain.xml
drwxr-xr-x  2 501 games 4096 Jul  7 15:28 customize
-rw-r--r--  1 501 games 4286 Mar 27  2017 favicon.ico
drwxrwxrwx  2 501 games 4096 Mar 27  2017 files   【权限为777】
drwxr-xr-x  5 501 games 4096 Jul  7 15:28 install
-rw-r--r--  1 501 games  105 Mar 27  2017 robots.txt

drwxr-xr-x  6 501 games 4096 Mar 27  2017 themes


[root@VM_0_11_centos web]# cd /var/www/edusoho
[root@VM_0_11_centos web]# ls
api  app  bootstrap  plugins  README.html  src  vendor  vendor_user  web
[root@VM_0_11_centos web]# cd web
[root@VM_0_11_centos web]# ls
app_dev.php  assets   crossdomain.xml  favicon.ico  install     themes
app.php      bundles  customize        files        robots.txt
[root@VM_0_11_centos web]# ll
total 48
-rw-r--r--  1 apache apache 2157 Jul  7 15:29 app_dev.php
-rw-r--r--  1 apache apache 1931 Jul  7 15:29 app.php
drwxr-xr-x  8 apache apache 4096 Jul  7 15:29 assets
drwxr-xr-x 14 apache apache 4096 Jul  7 15:29 bundles
-rw-r--r--  1 apache apache  323 Jul  7 15:29 crossdomain.xml
drwxr-xr-x  2 apache apache 4096 Jul  7 15:29 customize
-rw-r--r--  1 apache apache 4286 Jul  7 15:29 favicon.ico
drwxr-xr-x  2 apache apache 4096 Jul  7 15:29 files  【权限为755】
drwxr-xr-x  5 apache apache 4096 Jul  7 15:29 install
-rw-r--r--  1 apache apache  105 Jul  7 15:29 robots.txt

drwxr-xr-x  6 apache apache 4096 Jul  7 15:29 themes

两个web中的files权限不同

[root@VM_0_11_centos web]# chmod -R 777 files  【更改权限】
[root@VM_0_11_centos web]# ll
total 48
-rw-r--r--  1 root root 2157 Jul  7 16:48 app_dev.php
-rw-r--r--  1 root root 1931 Jul  7 16:48 app.php
drwxr-xr-x  8 root root 4096 Jul  7 16:48 assets
drwxr-xr-x 14 root root 4096 Jul  7 16:48 bundles
-rw-r--r--  1 root root  323 Jul  7 16:48 crossdomain.xml
drwxr-xr-x  2 root root 4096 Jul  7 16:48 customize
-rw-r--r--  1 root root 4286 Jul  7 16:48 favicon.ico
drwxrwxrwx  2 root root 4096 Jul  7 16:48 files
drwxr-xr-x  5 root root 4096 Jul  7 16:48 install
-rw-r--r--  1 root root  105 Jul  7 16:48 robots.txt
drwxr-xr-x  6 root root 4096 Jul  7 16:48 themes

[root@VM_0_11_centos web]# systemctl restart httpd php-fpm

注:

 edusoho比较特殊必须通过 www.edusoho2.com/install/start-install.php访问

完成...

猜你喜欢

转载自blog.csdn.net/weixin_42594318/article/details/80950005