Created
July 2, 2013 08:19
-
-
Save glader/5907597 to your computer and use it in GitHub Desktop.
Fab script to install phpmyadmin with nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
from fabric.contrib.files import exists, append, upload_template, sed | |
config = """ | |
server { | |
listen 80; | |
server_name localhost; | |
location /phpmyadmin { | |
root /var/www/; | |
index index.php index.html index.htm; | |
location ~ ^/phpmyadmin/(.+\.php)$ { | |
try_files $uri =404; | |
root /var/www/; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
include /etc/nginx/fastcgi_params; | |
} | |
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { | |
root /var/www/; | |
} | |
} | |
} | |
""" | |
def install_phpmyadmin(): | |
with settings(user='root'): | |
run('apt-get update') | |
run('apt-get install -y php5-cli mysql-client php5-mysql php5-fpm php5-cgi') | |
with cd('/tmp'): | |
run('rm -rf phpMyAdmin*') | |
run('wget http://kaz.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.3/phpMyAdmin-4.0.3-all-languages.tar.gz') | |
run('tar -zxf phpMyAdmin-4.0.3-all-languages.tar.gz') | |
run('rm -rf /var/www/phpmyadmin') | |
run('mkdir -p /var/www/phpmyadmin') | |
run('mv -f /tmp/phpMyAdmin-4.0.3-all-languages/* /var/www/phpmyadmin') | |
run('chown -R www-data:www-data /var/www/phpmyadmin') | |
run('chmod 755 /var/www/phpmyadmin/*.php') | |
run('cp /var/www/phpmyadmin/config.sample.inc.php /var/www/phpmyadmin/config.inc.php') | |
sed('/var/www/phpmyadmin/config.inc.php', 'localhost', MYSQL_HOST) | |
run('/etc/init.d/php5-fpm restart') | |
run('/etc/init.d/nginx restart') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment