前言:
- mediawiki运行环境要求:MediaWiki requires PHP 5.5.9+ and either MySQL 5.0.2+, MariaDB,
- 关于php升级,请看:CentOS6/7 yum 安装/升级PHP7.0
1. 系统:centos_7
2. php:PHP 7.0.22 (cli)
3. 数据库:mysql Ver 15.1 Distrib 5.5.52-MariaDB,
创建文件:
1.vim /etc/yum.repos.d/nginx.repo
添加如下代码
1.[nginx]
2.name=nginx repo
3.baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
4.gpgcheck=0
5.enabled=1
OS
改为centos
或者rhel
OSRELEASE
改为6/7
对应系统版本1.yum install -y nginx
1.[root@localhost lcr]# whereis nginx
2.nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
其中
1./etc/neginx
包含了nginx的配置文档
1.[root@localhost lcr]# cd /etc/nginx/
2.[root@localhost nginx]# ls
3.conf.d koi-utf mime.types nginx.conf uwsgi_params
4.fastcgi_params koi-win modules scgi_params win-utf
5.[root@localhost nginx]# cd conf.d/
6.[root@localhost conf.d]# ls
7.default.conf
其中conf.d
包含了nginx的配置文件
1.[root@localhost conf.d]# cat default.conf
2.server {
3. listen 80; <---监听端口
4. server_name localhost;
5.
6. #charset koi8-r;
7. #access_log /var/log/nginx/host.access.log main;
8.
9. location / {
10. root /usr/share/nginx/html; <--网页文件的存放目录
11. index index.html index.htm; <--表明首页文件的类型
12. }
13.
14. #error_page 404 /404.html;
15.
16. # redirect server error pages to the static page /50x.html
17. #
18. error_page 500 502 503 504 /50x.html;
19. location = /50x.html {
20. root /usr/share/nginx/html;
21. }
22.
23. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
24. #
25. #location ~ \.php$ {
26. # proxy_pass http://127.0.0.1;
27. #}
28.
29. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
30. #
31. #location ~ \.php$ {
32. # root html;
33. # fastcgi_pass 127.0.0.1:9000;
34. # fastcgi_index index.php;
35. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
36. # include fastcgi_params;
37. #}
38.
39. # deny access to .htaccess files, if Apache's document root
40. # concurs with nginx's one
41. #
42. #location ~ /\.ht {
43. # deny all;
44. #}
45.}
46.
其中
1.root /usr/share/nginx/html; <--网页文件的存放目录
2. index index.html index.htm; <--表明首页文件的类型
首先移动到nginx的应用目录下
1.cd /usr/share/nginx/html
1.wget https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz
1.tar -xzvf mediawiki-1.29.0.tar.gz
为了方便访问,将解压出来的文件移动到目录mediawiki
1.mv mediawiki-1.29.0 mediawiki
浏览器访问:localhost/mediawiki/index.php
页面未打开但是下载文件
打开内容如下:
1.<?php
2./**
3. * This is the main web entry point for MediaWiki.
4. *
5. * If you are reading this in your web browser, your server is probably
6. * not configured correctly to run PHP applications!
7. *
8. * See the README, INSTALL, and UPGRADE files for basic setup instructions
9. * and pointers to the online documentation.
10. *
11. * https://www.mediawiki.org/wiki/Special:MyLanguage/MediaWiki
12. *
13. * ----------
14. *
15. * This program is free software; you can redistribute it and/or modify
16. * it under the terms of the GNU General Public License as published by
17. * the Free Software Foundation; either version 2 of the License, or
18. * (at your option) any later version.
19. *
20. * This program is distributed in the hope that it will be useful,
21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23. * GNU General Public License for more details.
24. *
25. * You should have received a copy of the GNU General Public License along
26. * with this program; if not, write to the Free Software Foundation, Inc.,
27. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28. * http://www.gnu.org/copyleft/gpl.html
29. *
30. * @file
31. */
32.
33.// Bail on old versions of PHP, or if composer has not been run yet to install
34.// dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
35.// @codingStandardsIgnoreStart MediaWiki.Usage.DirUsage.FunctionFound
36.require_once dirname( __FILE__ ) . '/includes/PHPVersionCheck.php';
37.// @codingStandardsIgnoreEnd
38.wfEntryPointCheck( 'index.php' );
39.
40.require __DIR__ . '/includes/WebStart.php';
41.
42.$mediaWiki = new MediaWiki();
43.$mediaWiki->run();
查阅资料,nginx与php之间需要修改配置才可以配合使用
1.server {
2. listen 80;
3. server_name localhost;
4.
5. #charset koi8-r;
6. #access_log /var/log/nginx/host.access.log main;
7.
8. location / {
9. root /usr/share/nginx/html;
10. index index.html index.htm;
11. }
12.
13. #error_page 404 /404.html;
14.
15. # redirect server error pages to the static page /50x.html
16. #
17. error_page 500 502 503 504 /50x.html;
18. location = /50x.html {
19. root /usr/share/nginx/html;
20. }
21.
22. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
23. #
24. #location ~ \.php$ {
25. # proxy_pass http://127.0.0.1;
26. #}
27.
28. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
29. #
30. location ~ \.php$ {
31. root /usr/share/nginx/html;
32. fastcgi_pass 127.0.0.1:9000;
33. fastcgi_index index.php;
34. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
35. include fastcgi_params;
36. }
37.
38. # deny access to .htaccess files, if Apache's document root
39. # concurs with nginx's one
40. #
41. #location ~ /\.ht {
42. # deny all;
43. #}
44.}
1. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
2. #
3. #location ~ \.php$ {
4. # root html;
5. # fastcgi_pass 127.0.0.1:9000;
6. # fastcgi_index index.php;
7. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
8. # include fastcgi_params;
9. #}
10.
#
1.root /usr/share/nginx/html; #指定php解析的文件路径
1.fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1、安装php-fpm
1.yum install php70w-fpm
2、启动php-fpm
1./usr/sbin/php-fpm
3、设置php-fpm开机启动
1.service nginx reload
1、查看进程
1.netstat -lntup | egrep "nginx|php-fpm"
1.[root@centos-1 nginx]# netstat -lntup | egrep "nginx|php-fpm"
2.tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 13327/php-fpm: mast
3.tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13385/nginx: master
2、查看php运行状况
1.vim /usr/share/nginx/html/info.php
输入一下内容
1.<?php
2.phpinfo()
3.?>
浏览器访问:localhost/info.php
看到如下内容,说明nginx与php的整合完成
mediawiki
浏览器访问:
http://localhost/mediawiki/index.php
10、将LocalSetting
移动到mediawiki下
1.[root@centos-1 lcr]# mv LocalSettings.php /usr/share/nginx/html/mediawiki
11、访问:http://localhost/mediawiki/index.php
12、局域网访问mediawiki
无法访问
因为初始化mediawiki的时候使用的链接是:localhost/mediawiki/index.php
指定了服务器的地址为:http://localhost
修改配置文件:LocalSetting.php
1.## The protocol and server name to use in fully-qualified URLs
2.$wgServer = "http://localhost";
改为:
1.## The protocol and server name to use in fully-qualified URLs
2.$wgServer = "http://192.168.121.21";
1.systemctl start mariadb
1.systemctl enable mariadb
1.mysql_secure_installation
1.[root@centos-1 nginx]# mysql_secure_installation
2.
3.NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
4. SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
5.
6.In order to log into MariaDB to secure it, we'll need the current
7.password for the root user. If you've just installed MariaDB, and
8.you haven't set the root password yet, the password will be blank,
9.so you should just press enter here.
10.
11.Enter current password for root (enter for none): <---有用是初始化,没有密码,直接按enter
12.OK, successfully used password, moving on...
13.
14.Setting the root password ensures that nobody can log into the MariaDB
15.root user without the proper authorisation.
16.
17.Set root password? [Y/n] Y <---设置root账号密码
18.New password:
19.Re-enter new password:
20.Password updated successfully!
21.Reloading privilege tables..
22. ... Success!
23.
24.
25.By default, a MariaDB installation has an anonymous user, allowing anyone
26.to log into MariaDB without having to have a user account created for
27.them. This is intended only for testing, and to make the installation
28.go a bit smoother. You should remove them before moving into a
29.production environment.
30.
31.Remove anonymous users? [Y/n] y <---移除匿名账号
32. ... Success!
33.
34.Normally, root should only be allowed to connect from 'localhost'. This
35.ensures that someone cannot guess at the root password from the network.
36.
37.Disallow root login remotely? [Y/n] y <---禁止root账号远程登录
38. ... Success!
39.
40.By default, MariaDB comes with a database named 'test' that anyone can
41.access. This is also intended only for testing, and should be removed
42.before moving into a production environment.
43.
44.Remove test database and access to it? [Y/n] y <---移除测试数据库
45. - Dropping test database...
46. ... Success!
47. - Removing privileges on test database...
48. ... Success!
49.
50.Reloading the privilege tables will ensure that all changes made so far
51.will take effect immediately.
52.
53.Reload privilege tables now? [Y/n] y <---重新加载权限列表
54. ... Success!
55.
56.Cleaning up...
57.
58.All done! If you've completed all of the above steps, your MariaDB
59.installation should now be secure.
60.
61.Thanks for using MariaDB!
1.[root@centos-1 nginx]# mysql -uroot -p
2.Enter password:
3.Welcome to the MariaDB monitor. Commands end with ; or \g.
4.Your MariaDB connection id is 10
5.Server version: 5.5.52-MariaDB MariaDB Server
6.
7.Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
8.
9.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
10.
11.MariaDB [(none)]> create database wiki; <---创建数据库wiki
12.Query OK, 1 row affected (0.00 sec)
13.
14.MariaDB [(none)]> create user wikiuser@'localhost' identified by '775120';
15.Query OK, 0 rows affected (0.00 sec) <---创建用户wikiuser
16.
17.MariaDB [(none)]> grant all on wiki.* to wikiuser@localhost;
18.Query OK, 0 rows affected (0.01 sec) <---为wikiuser授权
19.
20.MariaDB [(none)]> flush privileges; <---刷新权限列表
21.Query OK, 0 rows affected (0.01 sec)
flush privileges;
非常重要,不执行这一步的话,会导致mediawiki无法写入数据至此,CentOS7 LNMP环境mediawiki安装完毕
点击回到fatcat的主页