centos 7安装 media wiki

centos7 安装MeidaWiki

官方文档中有详细的安装教程, 从php搭建到mysql安装
https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Red_Hat_Linux#Prerequisites:_Quick_Installation_of_Apache.2C_MySQL_and_PHP


环境准备

# centos7 中默认没有iptables服务, 需要安装
# yum -y install iptables-services

# 打开80端口
# vim /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
[color=blue]-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT[/color]
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT


# service iptables start
# chkconfig iptables on

# 关闭 SELINUX, 不关闭的话, php无法连接mysql, 重启后生效
# getenforce
Enforcing

# vim /etc/selinux/config
# SELINUX=enforcing
SELINUX=disabled


安装httpd php mysql, mysql可以使用官方的rpm安装
# yum install -y httpd
# chkconfig httpd on

# yum install -y mariadb-server
# yum install -y php
# yum install -y php-mysql
# yum install -y php-xml
# yum install -y php-gd

# 可以直接使用
yum install httpd php php-mysql php-gd php-xml mariadb-server mariadb

启动httpd mariadb
# service httpdstart
# service mariadb start


[root@confluence application]# service mariadb start
Redirecting to /bin/systemctl start  mariadb.service
[root@confluence application]# service mariadb stop
Redirecting to /bin/systemctl stop  mariadb.service



配置mysql数据库和用户名 密码
# mysql -uroot -p
MariaDB [(none)]> select user,password,host from mysql.user;
+------+----------+-----------------+
| user | password | host            |
+------+----------+-----------------+
| root |          | localhost       |
| root |          | confluence.demo |
| root |          | 127.0.0.1       |
| root |          | ::1             |
|      |          | localhost       |
|      |          | confluence.demo |
+------+----------+-----------------+
6 rows in set (0.00 sec)

MariaDB [(none)]> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)

MariaDB [(none)]> update mysql.user set password=password('lidongxu');
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [(none)]> create user 'mediawiki'@'%' identified by 'mediawiki';

MariaDB [(none)]> create database media_wiki default character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on media_wiki.* to 'mediawiki'@'%';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| media_wiki         |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)


MariaDB [(none)]> show grants for 'mediawiki'@'%';
+----------------------------------------------------------------------------------------------------------+
| Grants for mediawiki@%                                                                                   |
+----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mediawiki'@'%' IDENTIFIED BY PASSWORD '*4F6EE014DDE9001FA0493667C4216A3DA644B46A' |
| GRANT ALL PRIVILEGES ON `media_wiki`.* TO 'mediawiki'@'%'                                                |
+----------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> show grants for 'mediawiki';
+----------------------------------------------------------------------------------------------------------+
| Grants for mediawiki@%                                                                                   |
+----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mediawiki'@'%' IDENTIFIED BY PASSWORD '*4F6EE014DDE9001FA0493667C4216A3DA644B46A' |
| GRANT ALL PRIVILEGES ON `media_wiki`.* TO 'mediawiki'@'%'                                                |
+----------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)



开机启动httpd mariadb
[root@confluence application]# systemctl enable httpd
[root@confluence application]# systemctl enable mariadb




2. 下载安装包
# mkdir -p /application/download
# cd /application/download/
# wget http://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.0.tar.gz

# curl -O https://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.0.tar.gz.sig
# tar -zxvf mediawiki-1.26.0.tar.gz


# cd /var/www/
# cp -R /application/download/mediawiki-1.26.0 /var/www/html/
# mv /var/www/html/mediawiki-1.26.0/ /var/www/html/mediawiki
# chown -R apache.apache /var/www/html/mediawiki/




如果需要使用域名
假设 mediawiki目录为
/var/www/web/mediawiki/

# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Aug 24 2015 18:11:25

# 需要把不同域名配置在不同目录
# cd /etc/httpd/conf.d/
# vim mediawiki.conf
<VirtualHost *:80>
   ServerName mediawiki.example.com
   DocumentRoot /var/www/web/mediawiki/
</VirtualHost>
# https://www.mediawiki.org/wiki/Manual:Security#Upload_security 安全配置
<Directory "/var/www/web/mediawiki/images">
   # Ignore .htaccess files
   AllowOverride None
   # Server HTML as plaintext, don't execute SHTML
   AddType text/plain .html .htm .shtml .php .phtml .php5

   # Don't run arbitrary PHP code
   php_admin_flag engine off

   # if you're other scrioting languages, disablr them too.
</Directory>




访问url后安装media wiki, 安装后会生成LocalSettings.php, 放入mediaWiki根目录就可以正常使用了(和media wiki的 index.php一个目录)





你可能感兴趣的:(centos,mediawiki)