搭建smartwiki需要四个组件
- nginx
- php
- msyql
- smartwiki源码
参考资料:
源码地址:https://github.com/lifei6671/SmartWiki
smartwiki官网:https://www.iminho.me/
首先搭建php环境
检查当前环境是否有php
yum list installed | grep php
如果有安装的PHP包,先删除他们
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
下载PHP软件仓库:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
(如果想删除上面安装的包,重新安装 可以rpm -qa | grep webstatic 然后 rpm -e 上面搜索到的包即可)
安装php包
yum -y install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
安装php-fpm
yum -y install php56w-fpm
查看php版本
php -v
到这里php环境就搭建好了,php-fpm是什么呢?FPM(FastCGI 进程管理器)用于替换PHP FastCGI 的大部分附加功能,对于高负载网站是非常有用的。
启动php-fpm
/usr/sbin/php-fpm
lsof -i:9000 查看是否启动
安装smartwiki
下载源码
git clone -b release https://github.com/lifei6671/SmartWiki.git
设置目录权限
在 SmartWiki 根目录执行
sudo chmod -R 0777 storage
sudo chmod -R 0777 public
sudo chmod -R 0777 vendor
添加配置文件并设置加密密钥
生成配置文件
mv .env.example .env
设置配置文件权限
sudo chmod 0777 .env
生成加密密钥
php artisan key:generat
nginx配置安装
yum -y install nginx
vim /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name wiki.puhuijia.com;
charset utf-8;
set $root_path '/smartwiki/SmartWiki/public';
root $root_path;
try_files $uri $uri/ @rewrite;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
}
}
重启nginx
service nginx restart
安装mysql
我们使用yum的方式来安装mysql5.7
下载安装包仓库:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
然后进行repo的安装
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
安装mysql
yum -y install mysql-server
启动关闭
systemctl start mysqld #启动MySQL
systemctl stop mysqld #关闭MySQL
systemctl restart mysqld #重启MySQL
systemctl status mysqld #查看MySQL运行状态
systemctl enable mysqld #设置开机启动
systemctl disable mysqld #关闭开机启动
查看初始密码:
grep 'temporary password' /var/log/mysqld.log
登录
mysql -uroot -p
初次修改root密码
set global validate_password_policy=0;
取消密码长度限制
ALTER USER USER() IDENTIFIED BY '12345678';
至此smartwiki搭建成功,浏览器输入IP/index.php进行后续设置。