Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save angelotinho/a0e47a3e6c7cc2bae608e5ad4178e3f2 to your computer and use it in GitHub Desktop.
Save angelotinho/a0e47a3e6c7cc2bae608e5ad4178e3f2 to your computer and use it in GitHub Desktop.
Install & Setup WordPress

Install & Setup WordPress Gittip

Author: Josef Jezek

Install

Ubuntu / Debian

Install LAMP Server

# Packages for latest PHP
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo tasksel install lamp-server
sudo apt-get install php5-gd php5-curl php5-cgi php5-dev php5-mcrypt php5-pspell php-apc php5-imagick phpmyadmin
wget -y
sudo a2enmod rewrite ssl actions
sudo a2dismod php5
sudo service apache2 restart

# MariaDB
http://stackoverflow.com/questions/16214517/installing-mariadb-unmet-dependencies-mariadb-server-5-5

# NGINX
http://www.organic-development.com/blog/apache-vs-nginx-performance-comparison.html
http://systemsarchitect.net/apache2-vs-nginx-for-php-application

Install LEMP Server

# Latest Nginx Stable repository NO
# sudo add-apt-repository ppa:nginx/stable
# Latest Nginx Custom repository
sudo add-apt-repository ppa:brianmercer/nginx
# Latest PHP 5.4
sudo add-apt-repository ppa:ondrej/php5
# Latest phpMyAdmin
sudo add-apt-repository ppa:nijel/phpmyadmin

sudo apt-get update

sudo apt-get install mysql-server
sudo vi /etc/mysql/conf.d/wordpress_1CPU_1GB.cnf
sudo service mysql restart

sudo apt-get install nginx-custom wget -y
sudo apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-cgi php5-curl php5-gd php5-cli php5-fpm php-apc php5-dev php5-mcrypt php5-intl php5-tidy php5-imagick php5-pspell php-pear phpmyadmin -y

sudo vi /etc/nginx/nginx.conf
# For 1 CPU
worker_processes 1;

events {
        worker_connections 256;
}

http {
        server_tokens off;
        client_max_body_size 8m;
        reset_timedout_connection on;
        index index.php index.html index.htm;
        upstream php5-fpm {
                keepalive 8;
                server unix:/var/run/php5-fpm.sock;
        }
}


sudo vi /etc/nginx/conf.d/wordpress-mu.conf
sudo vi /etc/nginx/conf.d/restrictions.conf

sudo chown -R www-data:www-data /var/www/wordpress

sudo service nginx configtest
sudo service nginx restart
sudo tail /var/log/nginx/error.log

Install WordPress

Check Download page for latest version of WordPress and update VERSION - only for czech lang

wget -O wordpress.tar.gz http://wordpress.org/latest.tar.gz
# VERSION=3.5.1
# wget -O wordpress.tar.gz http://cs.wordpress.org/wordpress-$VERSION-cs_CZ.tar.gz
tar xzf wordpress.tar.gz
sudo cp -R wordpress /var/www
sudo chown -R www-data /var/www/wordpress

mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpress-user';
SET PASSWORD FOR 'wordpress-user' = PASSWORD("wpass321*");
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress-user'@localhost IDENTIFIED BY 'wpass321*';
FLUSH PRIVILEGES;
exit

sudo vi /var/www/wordpress/.htaccess
RewriteBase /
RewriteRule . /index.php [L]

sudo vi /etc/apache2/sites-available/wordpress
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/wordpress

    <Directory /var/www/wordpress>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    LogLevel warn
    ErrorLog /var/log/apache2/wordpress_error.log
    CustomLog /var/log/apache2/wordpress_access.log combined

    RewriteEngine On
    # Redirect http to https
#    RewriteCond %{HTTPS} off
#    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    # Remove www prefix
#    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
#    RewriteRule ^\/?(.*)$ http://example.com/$1 [R=301,L]

    # Add www prefix
    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule (.*) http://www.example.com$1 [R=301]

    # Settings for CGI
    ScriptAlias /local-bin /usr/bin
    AddHandler application/x-httpd-php5 php
    Action application/x-httpd-php5 /local-bin/php-cgi
    
    Alias /data /media/data
    <Directory /media/data>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

sudo vi /etc/apache2/sites-available/wordpress-ssl
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/wordpress

    <Directory /var/www/wordpress>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    LogLevel warn
    ErrorLog /var/log/apache2/wordpress_ssl_error.log
    CustomLog /var/log/apache2/wordpress_ssl_access.log combined

    RewriteEngine On
    # Remove www prefix
#    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
#    RewriteRule ^\/?(.*)$ https://example.com/$1 [R=301,L]

    # Add www prefix
    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule (.*) http://www.example.com$1 [R=301]

    SSLEngine on
    SSLCertificateFile    /etc/ssl/certs/cert-example.com.crt
    SSLCertificateKeyFile /etc/ssl/private/cert-example.com.key

    # Settings for CGI
    ScriptAlias /local-bin /usr/bin
    AddHandler application/x-httpd-php5 php
    Action application/x-httpd-php5 /local-bin/php-cgi
</VirtualHost>

# Create self-signed SSL Certificate
DOMAIN=example.com
[email protected]
sudo openssl genrsa -out /etc/ssl/private/cert-$DOMAIN.key 1024 && echo -ne "\n\n\n\n\n$DOMAIN\n$ADMIN\n" | sudo openssl req -new -key /etc/ssl/private/cert-$DOMAIN.key -x509 -out /etc/ssl/certs/cert-$DOMAIN.crt -days 999

sudo a2ensite wordpress wordpress-ssl
sudo service apache2 reload

Setup

sudo vi /var/www/wordpress/wp-config.php
define('WPLANG', 'cs_CZ');
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
define('DISABLE_WP_CRON', true);
define('WP_ALLOW_MULTISITE', true);

sudo crontab -e
*/5 * * * * /usr/bin/php5 -q /var/www/wordpress/wp-cron.php > /dev/null 2>&1

sudo vi /var/www/wordpress/.htaccess
# protect wp-config
<files wp-config.php>
order deny,allow
deny from all
</files>
# protect wp-cron
<files wp-cron.php>
order deny,allow
deny from all
</files>

DokuWiki

Security

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment