setup wiki in Linux

Refer to https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Red_Hat_Linux

  1. A fresh linux env.
  2. Install operating system packages.
    •   yum install httpd php php-mysql php-gd mysql-server php-xml mysql

                        i. yum install httpd php php-mysql php-gd php-xml mariadb-server mariadb           (for RHLD7)

    •   yum -y install libxml2

[root@vszcfpe01 ~]# yum install php

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

aa                                       | 3.9 kB     00:00 ...

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package php.x86_64 0:5.3.3-22.el6 will be installed

--> Processing Dependency: php-common(x86-64) = 5.3.3-22.el6 for package: php-5.3.3-22.el6.x86_64

--> Processing Dependency: php-cli(x86-64) = 5.3.3-22.el6 for package: php-5.3.3-22.el6.x86_64

--> Running transaction check

---> Package php-cli.x86_64 0:5.3.3-22.el6 will be installed

---> Package php-common.x86_64 0:5.3.3-22.el6 will be installed

--> Finished Dependency Resolution

 Dependencies Resolved

 ================================================================

Package         Arch        Version              Repository

                                                           Size

================================================================

Installing:

php             x86_64      5.3.3-22.el6         aa      1.1 M

Installing for dependencies:

php-cli         x86_64      5.3.3-22.el6         aa      2.2 M

php-common      x86_64      5.3.3-22.el6         aa      524 k

 

Transaction Summary

================================================================

Install       3 Package(s)

 

Total download size: 3.8 M

Installed size: 13 M

Is this ok [y/N]: y

Downloading Packages:

----------------------------------------------------------------

Total                            57 MB/s | 3.8 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : php-common-5.3.3-22.el6.x86_64               1/3

  Installing : php-cli-5.3.3-22.el6.x86_64                  2/3

  Installing : php-5.3.3-22.el6.x86_64                      3/3

aa/productid                             | 1.7 kB     00:00 ...

  Verifying  : php-cli-5.3.3-22.el6.x86_64                  1/3

  Verifying  : php-common-5.3.3-22.el6.x86_64               2/3

  Verifying  : php-5.3.3-22.el6.x86_64                      3/3

 

Installed:

  php.x86_64 0:5.3.3-22.el6                                    

 

Dependency Installed:

  php-cli.x86_64 0:5.3.3-22.el6                                

  php-common.x86_64 0:5.3.3-22.el6                             

 

Complete!

[root@vszcfpe01 ~]# yum install php-mysql

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package php-mysql.x86_64 0:5.3.3-22.el6 will be installed

--> Processing Dependency: php-pdo(x86-64) for package: php-mysql-5.3.3-22.el6.x86_64

--> Running transaction check

---> Package php-pdo.x86_64 0:5.3.3-22.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================

Package         Arch         Version            Repository

                                                           Size

================================================================

Installing:

php-mysql       x86_64       5.3.3-22.el6       aa        81 k

Installing for dependencies:

php-pdo         x86_64       5.3.3-22.el6       aa        75 k

 Transaction Summary

================================================================

Install       2 Package(s)

 

Total download size: 155 k

Installed size: 383 k

Is this ok [y/N]: y

Downloading Packages:

----------------------------------------------------------------

Total                            21 MB/s | 155 kB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : php-pdo-5.3.3-22.el6.x86_64                  1/2

  Installing : php-mysql-5.3.3-22.el6.x86_64                2/2

  Verifying  : php-pdo-5.3.3-22.el6.x86_64                  1/2

  Verifying  : php-mysql-5.3.3-22.el6.x86_64                2/2

 

Installed:

  php-mysql.x86_64 0:5.3.3-22.el6                              

 

Dependency Installed:

  php-pdo.x86_64 0:5.3.3-22.el6                                

 

Complete!

[root@vszcfpe01 ~]# yum install php-gd

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package php-gd.x86_64 0:5.3.3-22.el6 will be installed

-o-> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================

Package      Arch         Version               Repository

                                                           Size

================================================================

Installing:

php-gd       x86_64       5.3.3-22.el6          aa       106 k

 

Transaction Summary

================================================================

Install       1 Package(s)

 

Total download size: 106 k

Installed size: 324 k

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : php-gd-5.3.3-22.el6.x86_64                   1/1

  Verifying  : php-gd-5.3.3-22.el6.x86_64                   1/1

 

Installed:

  php-gd.x86_64 0:5.3.3-22.el6                                  

 

Complete!

[root@vszcfpe01 ~]# yum install mysql-server

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package mysql-server.x86_64 0:5.1.66-2.el6_3 will be installed

--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.66-2.el6_3.x86_64

--> Running transaction check

---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================

Package            Arch       Version             Repository

                                                           Size

================================================================

Installing:

mysql-server       x86_64     5.1.66-2.el6_3      aa     8.6 M

Installing for dependencies:

perl-DBD-MySQL     x86_64     4.013-3.el6         aa     134 k

 

Transaction Summary

================================================================

Install       2 Package(s)

 

Total download size: 8.7 M

Installed size: 25 M

Is this ok [y/N]: y

Downloading Packages:

----------------------------------------------------------------

Total                            87 MB/s | 8.7 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64            1/2

  Installing : mysql-server-5.1.66-2.el6_3.x86_64           2/2

  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64            1/2

  Verifying  : mysql-server-5.1.66-2.el6_3.x86_64           2/2

 

Installed:

  mysql-server.x86_64 0:5.1.66-2.el6_3                         

 

Dependency Installed:

  perl-DBD-MySQL.x86_64 0:4.013-3.el6                          

 

Complete!

[root@vszcfpe01 ~]# yum install ph--xml

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

No package ph--xml available.

Error: Nothing to do

[root@vszcfpe01 ~]# yum install php-xml

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package php-xml.x86_64 0:5.3.3-22.el6 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

================================================================

Package       Arch         Version              Repository

                                                           Size

================================================================

Installing:

php-xml       x86_64       5.3.3-22.el6         aa       103 k

 

Transaction Summary

================================================================

Install       1 Package(s)

 

Total download size: 103 k

Installed size: 307 k

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : php-xml-5.3.3-22.el6.x86_64                  1/1

  Verifying  : php-xml-5.3.3-22.el6.x86_64                  1/1

 

Installed:

  php-xml.x86_64 0:5.3.3-22.el6                                

 

Complete!

[root@vszcfpe01 ~]# yum install mysql

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Package mysql-5.1.66-2.el6_3.x86_64 already installed and latest version

Nothing to do

[root@vszcfpe01 ~]# yum install libxml2

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Package libxml2-2.7.6-8.el6_3.4.x86_64 already installed and latest version

Nothing to do

[root@vszcfpe01 ~]# yum install libxml2

Loaded plugins: product-id, refresh-packagekit, security,

              : subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Package libxml2-2.7.6-8.el6_3.4.x86_64 already installed and latest version

Nothing to do

[root@vszcfpe01 ~]#

 

  1. verify

[root@vszcfpe01 ~]# php -v

PHP 5.3.3 (cli) (built: Nov 29 2012 04:12:23)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

[root@vszcfpe01 ~]# service mysqld start

Initializing MySQL database:  Installing MySQL system tables...

OK

Filling help tables...

OK

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

 

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h vszcfpe01.amd.com password 'new-password'

 

Alternatively you can run:

/usr/bin/mysql_secure_installation

 

which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.

 

See the manual for more instructions.

 

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

 

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/mysql-test ; perl mysql-test-run.pl

 

Please report any problems with the /usr/bin/mysqlbug script!

 

                                                                                [  OK  ]

Starting mysqld:                                               [  OK  ]

 

  1. Database (MySQL) post-install configuration
    1. service mysqld start
    2. mysql_secure_installation

                                                               i.      root: mysql

[root@vszcfpe01 ~]# mysql_secure_installation

 

 

 

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

 

In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

 

Set root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

 

 

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] n

... skipping.

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] n

... skipping.

 

By default, MySQL comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

... Success!

 

Cleaning up...

 

 

 

All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.

 

Thanks for using MySQL!

 

  1. Log into MySQL client

[root@vszcfpe01 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 10

Server version: 5.1.66 Source distribution

 

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';                # Create the wiki user

Query OK, 0 rows affected (0.00 sec)

 

mysql> CREATE DATABASE wikidatabase;                     Create the database

Query OK, 1 row affected (0.00 sec)

 

mysql> GRANT ALL PRIVILEGES ON wikidatabase.* TO 'wiki'@'localhost';                       Grant privileges to newly created DB

Query OK, 0 rows affected (0.00 sec)

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

 

mysql> SHOW DATABASES;                 To confirm that it was created

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| wikidatabase       |

+--------------------+

3 rows in set (0.00 sec)

 

mysql> SHOW GRANTS FOR 'wiki'@'localhost';                           To display what has been granted:

+-------------------------------------------------------------------------------------------------------------+

| Grants for wiki@localhost                                                                                   |

+-------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'wiki'@'localhost' IDENTIFIED BY PASSWORD '*36B0067921ECA97BA575317EDCE0827EEAEBF35F' |

| GRANT ALL PRIVILEGES ON `wikidatabase`.* TO 'wiki'@'localhost'                                              |

+-------------------------------------------------------------------------------------------------------------+

2 rows in set (0.00 sec)

 

mysql> exit

Bye

 

  1. 6.       Download MediaWiki                     (Install mediawiki tarball)
cd /home/libs

wget http://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.2.tar.gz

[root@vszcfpe01 ~]# cd /var/www

[root@vszcfpe01 www]# ls

cgi-bin  error  html  icons

[root@vszcfpe01 www]# locate mediawiki

/etc/selinux/targeted/modules/active/modules/mediawiki.pp

/home/libs/mediawiki-1.26.2.tar.gz                        tar file location

/usr/share/man/man8/httpd_mediawiki_script_selinux.8.gz

/usr/share/selinux/devel/include/apps/mediawiki.if

/usr/share/selinux/targeted/mediawiki.pp.bz2

[root@vszcfpe01 www]# pwd

/var/www

[root@vszcfpe01 www]# tar -zxf /home/libs/mediawiki-1.26.2.tar.gz

[root@vszcfpe01 www]# ls

cgi-bin  error  html  icons  mediawiki-1.26.2

[root@vszcfpe01 www]# ln -s mediawiki-1.26.2/ mediawiki

[root@vszcfpe01 www]# chown -R apache:apache /var/www/mediawiki-1.26.2

[root@vszcfpe01 www]# ls                            

cgi-bin  error  html  icons  mediawiki  mediawiki-1.26.2

 

  1. 7.       Configure

Webserver (Apache) post-install configuration

Open /etc/httpd/conf/httpd.conf and search for and change these three lines:

        DocumentRoot "/var/www"
        <Directory "/var/www/mediawiki">     <-- this is the SECOND "<Directory" entry, not the 'root' one
        DirectoryIndex index.html index.html.var index.php

[root@vszcfpe01 www]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

[root@vszcfpe01 www]# vi /etc/httpd/conf/httpd.conf

[root@vszcfpe01 www]# pwd

/var/www

[root@vszcfpe01 www]# chown -R apache:apache /var/www/mediawiki-1.26.2

[root@vszcfpe01 www]# service httpd restart

Stopping httpd:                                                                 [  OK  ]

Starting httpd:                                                                    [  OK  ]

 

  1. Firewall configuration

system-config-firewall-tui            # open ports in ur firewall using

Enable both the https and http services (follow the instructions of the configuration interface).

[root@vszcfpe01 www]# system-config-firewall-tui

[root@vszcfpe01 www]# yum install system-config-firewall-tui

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Setting up Install Process

Package system-config-firewall-tui-1.2.27-5.el6.noarch already installed and latest version

Nothing to do

[root@vszcfpe01 www]# firewall-cmd --add-service=http                                                           ?????????

-bash: firewall-cmd: command not found

[root@vszcfpe01 www]# firewall-cmd --add-service=https                                                         ?????????

-bash: firewall-cmd: command not found

!!!!!!!!!!!!!!!!!be note that if firewall not disable, u MUST open 80 port then client can access webpage.

-          system-config-firewall-tui, remove enable then save/exit.

-          Or /etc/sysconfig/iptables, to add 1 column to enable 80 port as below

-          -A INPUT -m state --state NEW -m tcp -p tcp --dport 80  -j ACCEPT          

  1. Security (selinux) configuration

On a default Red Hat (or CentOS) install, the selinux package will be installed and enabled. You can check this using this command

If the command displays "enforcing" then you must either disable selinux (not recommended), or set the correct selinux context for the MediaWiki files, running these commands as root.

[root@vszcfpe01 www]# getenforce

Enforcing

[root@vszcfpe01 www]# restorecon -FR /var/www/mediawiki-1.26.2/

[root@vszcfpe01 www]# restorecon -FR /var/www/mediawiki

You can check for the correct context with

The media directories and links should have this context:

system_u:object_r:httpd_sys_content_t:s0

 

!!!!!! Disabling security (selinux)

If you are determined to disable selinux (instead of configuring it properly as detailed above), go to /etc/selinux and modify conf making it either "permissive" or "disabled." I also had to create a link to /usr/share/mediawiki-1.26.2/load.php in my /var/www/mediawiki directory and change the ownership on the /usr/share/mediawiki-1.26.2 directory to apache.apache

  1. Ensure your Apache and MySQL auto start when your server reboot.
    chkconfig httpd on
    chkconfig mysqld on
  2. Input website to test.

http://vszcfpe01/mediawiki

Yeah, it works.

 

  1. Config mediawiki.

Refer to http://blog.csdn.net/gao36951/article/details/43965527

 

 

 

 

 

Use same configure as you create in server: root pwd: mysql

 

 

administrator

 

 

 

 

 

  1. Key admin jobs:

Backup config:

#!/bin/sh

 

DAEMON_HOME=`dirname $0`

cd $DAEMON_HOME/../..

 

D=`date +%d`

DST1=/mnt/m/Backup/less

DST2=/mnt/z/venus/backup/less

 

# wake up Mi Router disk

rm -rf $DST1/dummy.txt

cp /tmp/AQI.txt $DST1/dummy.txt

 

# bin folder

cd /home/pi/git/home

tar cvzf $D.tar.gz bin

rm -rf $DST1/bin/$D.tar.gz

cp $D.tar.gz $DST1/bin

mv $D.tar.gz $DST2/bin

 

# crontjob

crontab -l > $DST1/crontab/$D.txt

crontab -l > $DST2/crontab/$D.txt

 

# Apache config

tar cvzf $D.tar.gz /etc/apache2

cp $D.tar.gz $DST1/apache

mv $D.tar.gz $DST2/apache

 

# dot files

cd $DST1/dotfiles

cp -rf ~pi/.bashrc ./.bashrc.$D

cp -rf ~pi/.mailcap ./.mailcap.$D

cp -rf ~pi/.gitconfig ./.gitconfig.$D

cp -rf ~pi/.offlineimaprc ./.offlineimaprc.$D

cp -rf ~pi/.msmtprc ./.msmtprc.$D

 

cd $DST2/dotfiles

cp -rf ~pi/.bashrc ./.bashrc.$D

cp -rf ~pi/.mailcap ./.mailcap.$D

cp -rf ~pi/.gitconfig ./.gitconfig.$D

cp -rf ~pi/.offlineimaprc ./.offlineimaprc.$D

cp -rf ~pi/.msmtprc ./.msmtprc.$D

 

# Git repo

cd $DAEMON_HOME/

tar czf $D.tar.gz /data/git

cp $D.tar.gz $DST1/git

mv $D.tar.gz $DST2/git

 

# TBD

Backup SQL:

backup SQL, refer to http://www.jb51.net/article/41570.htm

[root@www ~]# mysqldump -uroot --single-transaction --master-data=2 --databases hellodb > /backup/hellodb_`date +%F`.sql

--single-transaction: 基于此选项能实现热备InnoDB表;因此,不需要同时使用--lock-all-tables;
--master-data=2  记录备份那一时刻的二进制日志的位置,并且注释掉,1是不注释的
--databases hellodb 指定备份的数据库

然后回到mysql服务器端

load

 

  1. 为Mediawiki 配置:

Refer to http://blog.csdn.net/zzban/article/details/8483916

  1. 用户权限控制

/var/www/mediawiki/includes/DefaultSettings.php

禁用 àset true to false

  1. 添加自定义名字空间

/var/www/mediawiki/LocalSettings.php

在其最后添加如下代码:

    $wgExtraNamespaces = array(700 => "Yfzx", 701 => "Yfzx_Talk", 702 => "Gkzx", 703 => "Gkzx_Talk");

    require_once('extensions/NamespacePermissions.php');

    说明:

    700 => "Yfzx", 701 => "Yfzx_Talk"

              700,701表示名字空间ID,mediawiki要求自定义名字空间ID>=100,其中偶数表示名字空间,紧随其后的奇数表示该名字空间的讨论页

              Yfzx Yfzx_talk 表示名字空间名称和其对应讨论页 

创建步骤2中引用的PHP文件NamespacePermissions.php

在extensions目录下创建文件NamespacePermissions.php

  1. 设置权限

    1) 首先以管理员身份登录wiki

    2) 首页中点击‘特殊页面’或‘所有特殊页面’

    3) 找到并点击链接‘用户权限管理’

    4) 输入用户名并点击按钮

    5) 根据实际情况,为用户选择合适的名字空间权限,每个名字空间和其讨论页均对应权限RW(可读写)和RO(只读)

  1. asdfasdf

 

 

  1. change your wiki logo.

Update /var/www/mediawiki/resources/assets/wiki.png

Then refresh.

转载于:https://www.cnblogs.com/iory/p/9447516.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值