Mediawiki
From Attie's Wiki
(Difference between revisions)
(Created page with "===As Root=== <source lang="bash"> # install Nginx, PHP and MySQL apt-get install nginx php5-cli php5-cgi spawn-fcgi mysql-server mysql-client # fix the nginx config sed -re ...") |
m (→As www-data) |
||
(3 intermediate revisions by one user not shown) | |||
Line 2: | Line 2: | ||
<source lang="bash"> | <source lang="bash"> | ||
# install Nginx, PHP and MySQL | # install Nginx, PHP and MySQL | ||
− | apt-get install nginx php5-cli php5-cgi spawn-fcgi mysql-server mysql-client | + | apt-get install nginx php5-cli php5-cgi php5-mysql spawn-fcgi mysql-server mysql-client |
# fix the nginx config | # fix the nginx config | ||
Line 126: | Line 126: | ||
GRANT ALL PRIVILEGES ON wiki.* TO 'wiki'@'localhost' WITH GRANT OPTION; | GRANT ALL PRIVILEGES ON wiki.* TO 'wiki'@'localhost' WITH GRANT OPTION; | ||
EOF | EOF | ||
+ | </source> | ||
− | .. | + | ===As www-data=== |
+ | Download MediaWiki: http://www.mediawiki.org/wiki/Download | ||
+ | |||
+ | <source lang="bash"> | ||
+ | cd /home/wiki/htdocs | ||
+ | tar -xvf ${MEDIAWIKI} | ||
+ | O=mediawiki-* | ||
+ | mv mediawiki-*/* . | ||
+ | rm -rf ${O} | ||
+ | </source> | ||
+ | |||
+ | Now navigate to your server, and follow the steps | ||
+ | |||
+ | When you're done, delete the <code>mw-config</code> directory. | ||
+ | |||
+ | ===Anonymous Permissions=== | ||
+ | Add the following lines (with customisation) to your <code>LocalSettings.php</code> file: | ||
+ | <source lang="php"> | ||
+ | $wgGroupPermissions['*']['createaccount'] = false; | ||
+ | $wgGroupPermissions['*']['read'] = true; | ||
+ | $wgGroupPermissions['*']['edit'] = false; | ||
+ | $wgGroupPermissions['*']['createpage'] = false; | ||
+ | $wgGroupPermissions['*']['createtalk'] = false; | ||
+ | $wgGroupPermissions['*']['writeapi'] = false; | ||
</source> | </source> |
Latest revision as of 12:52, 14 February 2014
[edit] As Root
# install Nginx, PHP and MySQL apt-get install nginx php5-cli php5-cgi php5-mysql spawn-fcgi mysql-server mysql-client # fix the nginx config sed -re 's/^user[\t ][^;]+;*/user www-data;/' -i /etc/nginx/nginx.conf # make the directory structure mkdir -p /home/wiki/htdocs /home/wiki/logs chown -R www-data:www-data /home/wiki chmod -R 770 /home/wiki # squash the default config cat <<'EOF' >/etc/nginx/conf.d/default.conf server { listen 80; access_log /home/wiki/logs/access.log; error_log /home/wiki/logs/error.log; root /home/wiki/htdocs; location / { index index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/wiki/htdocs$fastcgi_script_name; } } EOF # setup PHP using FastCGI and named sockets cat <<'EOF' >/usr/bin/php-fastcgi #!/bin/bash FASTCGI_USER=www-data FASTCGI_GROUP=www-data SOCKET=/var/run/php-fastcgi/php-fastcgi.socket PIDFILE=/var/run/php-fastcgi/php-fastcgi.pid CHILDREN=6 PHP5=/usr/bin/php5-cgi /usr/bin/spawn-fcgi -s $SOCKET -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5 EOF chown root:root /usr/bin/php-fastcgi chmod 755 /usr/bin/php-fastcgi cat <<'EOF' >/etc/init.d/php-fastcgi #!/bin/bash PHP_SCRIPT=/usr/bin/php-fastcgi FASTCGI_USER=www-data FASTCGI_GROUP=www-data PID_DIR=/var/run/php-fastcgi PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid RET_VAL=0 case "$1" in start) if [[ ! -d $PID_DIR ]] then mkdir $PID_DIR chown $FASTCGI_USER:$FASTCGI_GROUP $PID_DIR chmod 0770 $PID_DIR fi if [[ -r $PID_FILE ]] then echo "php-fastcgi already running with PID `cat $PID_FILE`" RET_VAL=1 else $PHP_SCRIPT RET_VAL=$? fi ;; stop) if [[ -r $PID_FILE ]] then kill `cat $PID_FILE` rm $PID_FILE RET_VAL=$? else echo "Could not find PID file $PID_FILE" RET_VAL=1 fi ;; restart) if [[ -r $PID_FILE ]] then kill `cat $PID_FILE` rm $PID_FILE RET_VAL=$? else echo "Could not find PID file $PID_FILE" fi $PHP_SCRIPT RET_VAL=$? ;; status) if [[ -r $PID_FILE ]] then echo "php-fastcgi running with PID `cat $PID_FILE`" RET_VAL=$? else echo "Could not find PID file $PID_FILE, php-fastcgi does not appear to be running" fi ;; *) echo "Usage: php-fastcgi {start|stop|restart|status}" RET_VAL=1 ;; esac exit $RET_VAL EOF chown root:root /etc/init.d/php-fastcgi chmod 755 /etc/init.d/php-fastcgi update-rc.d php-fastcgi defaults /etc/init.d/php-fastcgi start /etc/init.d/nginx restart # setup a database and user for the wiki mysql -u root -p <<'EOF' CREATE USER 'wiki'@'localhost' IDENTIFIED BY '${PASSWORD}'; CREATE DATABASE wiki; GRANT ALL PRIVILEGES ON wiki.* TO 'wiki'@'localhost' WITH GRANT OPTION; EOF
[edit] As www-data
Download MediaWiki: http://www.mediawiki.org/wiki/Download
cd /home/wiki/htdocs tar -xvf ${MEDIAWIKI} O=mediawiki-* mv mediawiki-*/* . rm -rf ${O}
Now navigate to your server, and follow the steps
When you're done, delete the mw-config
directory.
[edit] Anonymous Permissions
Add the following lines (with customisation) to your LocalSettings.php
file:
$wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createpage'] = false; $wgGroupPermissions['*']['createtalk'] = false; $wgGroupPermissions['*']['writeapi'] = false;