Mediawiki
From Attie's Wiki
(Difference between revisions)
m |
m (→As www-data) |
||
Line 140: | Line 140: | ||
Now navigate to your server, and follow the steps | Now navigate to your server, and follow the steps | ||
+ | |||
+ | When you're done, delete the <code>mw-config</code> directory. |
Revision as of 12:32, 14 February 2014
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
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.