开源EyouCms博客安装教程
一、环境准备
博客官网地址与安装包下载:https://www.eyoucms.com/
(1)下载与解压blogs安装包
[root@blogs ~]# cd /var/www/html/ [root@blogs html]# unzip blogs.zip [root@blogs html]# mv blogs/* /var/www/html/
(2)站点文件权限配置
[root@blogs ~]# cd /var/www/ [root@blogs www]# chown apache:apache -R html/
(3)部署apache服务器
[root@blogs ~]# yum install httpd -y [root@blogs ~]# systemctl restart httpd.service
(4)安装PHP环境
博客环境要求:https://www.eyoucms.com/help/azwt/2020/1012/11028.html
[root@blogs ~]# yum install php-mysql php-gd libjpeg* php-imap php-ldap php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt php-odbc php-devel -y
【注】我这里使用的是云数据库MySQL5.7,需要将PHP升级到5.6版本。
[root@blogs ~]# yum remove php-common # 卸载老版php 国内源: # 安装EPEL源和Remi仓库 sudo yum install -y epel-release sudo rpm -Uvh https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm # 启用PHP 7.0仓库 sudo yum-config-manager --enable remi-php70 # 安装PHP sudo yum install -y php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
# 查看安装版本 [root@blogs ~]# php -v PHP 7.0.33 (cli) (built: Jun 5 2024 09:34:26) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
二、站点安装
2.1 容器化部署MySQL
文章推荐:Docker安装部署教程
[root@blogs ~]# cat Dockerfile FROM mysql:5.7 MAINTAINER star.gao RUN echo "alias ls='ls --color=auto'" >> /root/.bashrc \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ENV.UTF-8 [root@blogs ~]# docker build -t my-mysql:5.7 . # 构建容器 # 为了方便修改MySQL配置文件和MySQL数据文件安全,需将容器相关目录映射到宿主 [root@blogs ~]# docker run -itd -p 3306:3306 \ --restart=always \ --name=blogs_mysql \ -v /data/mysqldata/cnf:/etc/mysql \ -v /data/mysqldata/data:/var/lib/mysql \ --privileged=true \ -e MYSQL_ROOT_PASSWORD=ucloud.cn \ my-mysql:5.7 [root@blogs ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 468e1d34941e mysql:5.7 "docker-entrypoint..." 47 minutes ago Up 47 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp blogs_mysql
2.2 环境检查
2.3 配置系统
2.4 部署成功页面
2.5 版本升级
三、Apache证书部署
3.1 安装证书模块
[root@blogs ~]# yum install mod_ssl -y
3.2 主配置文件开启ssl模块支持
[root@blogs ~]# vim /etc/httpd/conf/httpd.conf LoadModule ssl_module modules/mod_ssl.so
[root@blogs ~]# systemctl restart httpd.service # 重启httpd服务
【注】重启完成后会在/etc/httpd/conf.d/目录下生成一个ssl.conf配置文件。
3.3 修改配置文件
(1)https配置
[root@blogs ~]# vim /etc/httpd/conf.d/ssl.conf Listen 443 https <VirtualHost _default_:443> #不要动,否则会报错 DocumentRoot "/var/www/html" ServerName www.starcto.com:443 #修改 SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA SSLCertificateFile /var/www/starcto/Apache/public.crt #修改 SSLCertificateKeyFile /var/www/starcto/Apache/private.key #修改 SSLCertificateChainFile /var/www/starcto/Apache/ca.crt #修改 </VirtualHost>
【注】除了上述四处需要修改,其余都不要动。
(2)http强制跳转https
[root@blogs ~]# vim /etc/httpd/conf.d/http.conf <VirtualHost *:80> ServerAdmin 1938418737@qq.com DocumentRoot /var/www/html/ ServerName starcto.com RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R] DirectoryIndex index.php ErrorLog /var/log/blog.starcto.com-error_log CustomLog /var/log/blog.starcto.com-access_log common </VirtualHost>
(3)手机域名配置
[root@blogs ~]# vim /etc/httpd/conf.d/http.conf <VirtualHost *:80> ServerAdmin 1938418737@qq.com DocumentRoot /var/www/html/ ServerName m.starcto.com RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R] DirectoryIndex index.php ErrorLog /var/log/blog.m.starcto.com-error_log CustomLog /var/log/blog.m.starcto.com-access_log common </VirtualHost>
[root@blogs ~]# vim /etc/httpd/conf.d/ssl.conf <VirtualHost _default_:443> DocumentRoot "/var/www/html" ServerName m.starcto.com:443 LogLevel warn SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA SSLCertificateFile /var/www/mstarcto/Apache/public.crt SSLCertificateKeyFile /var/www/mstarcto/Apache/private.key SSLCertificateChainFile /var/www/mstarcto/Apache/ca.crt </VirtualHost>
四、Nginx证书部署
4.1 PC域名证书部署
[root@ansible ~]# vim /etc/nginx/conf.d/starcto.com.conf server { listen 80; listen [::]:80; server_name starcto.com www.starcto.com; rewrite ^ https://$http_host$request_uri? permanent; } server { listen 443 ssl http2 ; listen [::]:443 ssl http2; server_name starcto.com www.starcto.com; ssl_certificate "/data/ssl/starcto.com/public.pem"; ssl_certificate_key "/data/ssl/starcto.com/private.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://10.25.203.134:8089; proxy_ssl_session_reuse off; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
4.2 手机域名证书部署
[root@ansible ~]# vim /etc/nginx/conf.d/m.starcto.com.conf server { listen 80; listen [::]:80; server_name m.starcto.com; rewrite ^ https://$http_host$request_uri? permanent; } server { listen 443 ssl http2 ; listen [::]:443 ssl http2; server_name m.starcto.com; ssl_certificate "/data/ssl/starcto.com/public.pem"; ssl_certificate_key "/data/ssl/starcto.com/private.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://10.25.203.134:8089; proxy_ssl_session_reuse off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
五、博客常用功能
5.1 博客搬家
https://www.eyoucms.com/ask/list_1_1/4014.html
(1)旧站点备份数据
(2)物理拷贝数据
# 迁移准备,拷贝站点数据 [root@blogs ~]# mkdir /root/blogs [root@blogs ~]# cd /var/www/ [root@blogs www]# cp -r html/* /root/blogs/ # 备份站点数据 [root@blogs ~]# tar -cvf blogs.tar.gz blogs/ # 压缩 [root@blogs ~]# scp blogs.tar.gz root@10.25.25.25:/root/ # 远程传输 [root@ansible ~]# tar -xvf blogs.tar.gz # 解压 [root@ansible ~]# cp -r blogs/* /var/www/html/ # 拷贝物理文件到站点目录
(3)修改目录文件配置
[root@ansible ~]# cd /var/www/html/ [root@ansible html]# cd install_1611285944/ [root@ansible install_1611285944]# ll total 6320 -rw-r--r-- 1 root root 406 Jul 17 19:57 auto.php -rw-r--r-- 1 root root 2150 Jul 17 19:57 config.php drwxr-xr-x 2 root root 24 Jul 17 19:57 css -rw-r--r-- 1 root root 6426243 Jul 17 19:57 eyoucms.sql drwxr-xr-x 2 root root 4096 Jul 17 19:57 images -rw-r--r-- 1 root root 31784 Jul 17 19:57 index.php -rw-r--r-- 1 root root 0 Jul 17 19:57 install.lock # 删除 drwxr-xr-x 2 root root 58 Jul 17 19:57 js drwxr-xr-x 2 root root 154 Jul 17 19:57 templates [root@ansible install_1611285944]# rm -rf install.lock
[root@ansible html]# mv install_1611285944/ install # 修改目录 [root@ansible html]# rm -rf data/runtime/* # 删除缓存和临时文件
(4)部署Apache服务
[root@ansible html]# yum install httpd -y
(5)安装博客
当安装过程中,如果出现某张表异常时,WEB页面备份时就忽略这张表,然后命令登录到数据库,手动创建表和表结构即可。
5.2 开发文档
https://www.eyoucms.com/doc/develop/
5.3 重置密码
https://www.eyoucms.com/ask/list_1_0/119.html
5.4 修改博客支持最大上传文件大小
[root@blogs-v2 ~]# find / -name php.ini /etc/php.ini [root@blogs-v2 ~]# vim /etc/php.ini ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 100M
5.5 强制去除index.php
[root@blogs-v2 ~]# vim /var/www/html/.htaccess RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [L] [root@blogs-v2 ~]# vim /etc/httpd/conf/httpd.conf LoadModule rewrite_module modules/mod_rewrite.so # 然后将httpd.conf文件里面的所有AllowOverride None都改为AllowOverride All
5.6 could not find driver
在一次重启服务器后,出现could not find driver报错,经过排查发现php有模块丢失,重新安装后恢复。
#(1)通过php -m |grep pdo_mysql 或php -m 查看php 扩展 [root@blogs-v2 ~]# php -m |grep pdo_mysql pdo_mysql [root@blogs-v2 ~]# php -m [PHP Modules] …… pdo_mysql …… #(2)如果发现缺少pdo_mysql扩展,可以执行下列命令安装 yum install php56w-mysql -y #(3)安装完成后,重启httpd服务 [root@blogs-v2 ~]# systemctl restart httpd.service
注:我这里使用的php版本是5.6,如果与我的版本不同,pdo_mysql扩展包的安装也会有所差异。
作者:UStarGao
链接:https://www.starcto.com/open-sourcing/187.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
UCloud云平台推荐
随便看看
- 2021-05-20Linux搭建GRE隧道教程
- 2021-07-21MySQL主从同步异常之Relay log异常1594
- 2021-09-24Postfix邮件服务器安装部署
- 2022-01-26MongoDB logicalSession打满导致业务出现cannot add session into the cache
- 2021-07-17开源EyouCms博客安装教程