Child pages
  • Wordpress on Debian
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This page describes the installation of Wordpress under Debian 7 (Wheezy), in an lxc container.

 

SITE_NAME=my.site.org ## Put the complete name (should match a valid, public DNS entry)
DB_NAME=$(hostname) ## Correct if the DB name does not match the host name
DB_USER_PASSWORD=$(pwgen 8 1)  ## Generates a random password
 
apt-get install wordpress nginx mysql-server php5-fpm


mysql -p << EOF
CREATE DATABASE ${DB_NAME};
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
ON ${DB_NAME}.*
TO ${DB_NAME}@localhost
IDENTIFIED BY '${DB_USER_PASSWORD}';
FLUSH PRIVILEGES;
EOF
 
cat > /etc/wordpress/config-${DB_NAME}.php << EOF
<?php
define('DB_NAME', '${DB_NAME}');
define('DB_USER', '${DB_NAME}');
define('DB_PASSWORD', '${DB_USER_PASSWORD}');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/var/lib/wordpress/wp-content');

/** IN URI INDEXOF THE CATEGORY*/
define('NUMBER_SLASH', '2');
define('NUMBER_SLASH2', '3');
define('CAT26', 'courses');

define( 'DB_CHARSET', 'utf8' );
?>
EOF


cat > /etc/nginx/sites-available/${DB_NAME} << EOF
server {
    listen 80;
    root /usr/share/wordpress;
    index index.php index.html index.htm;
    server_name ${SITE_NAME};
    access_log /var/log/nginx/${DB_NAME}.access.log;
    error_log /var/log/nginx/${DB_NAME}.error.log;  

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location /wp-content/ {
        root /var/lib/wordpress;
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 30d;
            log_not_found off;
        }
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        #fastcgi_intercept_errors on;
    }
}
EOF
 
ln -s ../sites-available/${DB_NAME} /etc/nginx/sites-enabled/  ## Activates the nginx config
nginx -t  ## Test the nginx config
service nginx restart
 
 

 

 

  • No labels