wget http://releases.wikimedia.org/mediawiki/1.25/mediawiki-1.25.2.tar.gz
tar zxvf mediawiki-1.25.2.tar.gz -C /var/www/
mv mediawiki-1.25.2/ mediawiki
yum install nginx
centos7安装nginx
# 下载对应当前系统版本的nginx包
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
# 建立nginx的yum仓库
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
# 下载并安装nginx
yum install nginx
yum install php php-devel
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
server {
server_name yourdomain;
root /var/www/mediawiki;
index index.php;
client_max_body_size 5m;
client_body_timeout 60;
access_log /tmp/wiki.log;
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args;
}
location ^~ /maintenance/ {
return 403;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ /cache/ {
deny all;
}
location /dumps {
root /var/www/mediawiki/local;
autoindex on;
}
}
fastcgi_params 注意这两行
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; ## 我的默认没有这行
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
php-cgi -b 127.0.0.1:9000
(后面使用php-fpm代替)
nginx -s reload
要设置mysql密码
mysql> set password for root@localhost = password('root');
选择配置,并将下载文件放入mediawiki根目录
https://meta.wikimedia.org/wiki/MediaWiki_Bulk_Page_Creator
baseurl = 'http://wiki.xxx.com/api.php'
def wiki_login():
data = {
"action": "login",
"lgname": "xxx",
"lgpassword": "xxx",
"format": "json",
}
r1 = requests.post(baseurl, data=data)
token = r1.json()['login']['token']
data2 = {"lgtoken": token}
data.update(data2)
r2 = requests.post(baseurl, data=data, cookies=r1.cookies)
return r2.cookies
def wiki_token():
data = {"action": "query","meta": "tokens", "format": "json", "type": "csrf"}
cookies = wiki_login()
r3 = requests.post(baseurl, data=data, cookies=cookies)
rsp = r3.json()
cookies = cookies.copy()
cookies.update(r3.cookies)
return rsp["query"]["tokens"]["csrftoken"], cookies
def wiki_edit(title, text):
headers = {'content-type': 'application/x-www-form-urlencoded'}
token, cookies = wiki_token()
data = {
"action": "edit",
"format": "json",
"title": title,
'summary': "summary",
"text": text,
"contentmodel": "wikitext",
"contentformat": "text/x-wiki",
"token": token,
}
r = requests.post(baseurl, data=data, headers=headers, cookies=cookies)
yum install php-fpm
进程可以理解以下信号
INT, TERM 立刻终止
QUIT 平滑终止
USR1 重新打开日志文件
USR2 平滑重载所有worker进程并重新载入配置和二进制模块
配置文件
/etc/php-fpm.conf
查看php-fpm进程数:
ps aux | grep -c php-fpm
直接操作
php-fpm 启动:
/usr/local/php/sbin/php-fpm
php-fpm 关闭:
kill -INT `cat /var/run/php-fpm/php-fpm.pid`
php-fpm 重启:
kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`
脚本操作
/etc/init.d/php-fpm start|stop|status|restart