Copy and paste it into a file under /etc/apt/sources.list.d/(we suggest naming the file MariaDB.list or something similar)
# MariaDB repository list - created 2012-09-04 06:29 UTC # http://downloads.mariadb.org/mariadb/repositories/ deb http://download.nus.edu.sg/mirror/mariadb/repo/5.5/ubuntu precise main deb-src http://download.nus.edu.sg/mirror/mariadb/repo/5.5/ubuntu precise main
sudo apt-get install nginx apache2 varnish vim-gnome
sudo apt-get install mariadb-common mariadb-server mariadb-client libmariadbclient-dev
Add the following
#/etc/apache2/ports.conf #NameVirtualHost *:80 #Listen 80 Listen 127.0.0.1:81
and
#/etc/apache2/sites-enabled/000-default ServerName localhost ServerAdmin webmaster@localhost DocumentRoot /var/www Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined
sudo apt-get install libapache2-mod-php5 sudo a2enmod php5
Check memory usage
- Top memory usage
ps -A --sort -rss -o comm,pmem
- Resident memory
ps -ylC apache2 --sort:rss
- All below for apache2.conf . MaxClients If your server has 1024MB of RAM and after booting the OS, you have 768MB free. If after starting up MySQL you have 700MB free and after starting up PureFTP you have 650MB free. Your Apache process RSS size is 17MB. That would mean you can run 38 Apache processes before you run out of RAM and begin to swap (your web server should never swap). Set MaxClients to 38 in this case.
- HostnameLookups Set this to "Off" otherwise Apache will do DNS lookups on client IPs for logging purposes and this is slow.
- AllowOverride Setting this to "None" will mean higher performance since Apache won't look for .htaccess files in each directory, HOWEVER many WordPress features (like nice URLs) require you to use .htaccess files so we need to compromise here and set this to "All" in most cases.
- MaxRequestsPerChild After this number of requests, a child process is killed and a new one forked to replace it. This ensures that any accidental memory leakage on the part of the Apache process cannot get out of hand. Setting this to something other than 0 means that Apache processes don't live forever.
- KeepAlive Off - we will handle keepalive on nginx
Change all dateformat to be Mariadb compliant.
find . -type f -name '*.php' -ls -exec sed -i s/0000-00-00\ 00:00:00/1000-01-01\ 00:00:00/ {} \;
CREATE DATABASE wordpress; GRANT ALL PRIVILEGES ON wordpress.* to "wordpressuser"@"localhost" identified by "password"; flush privileges;
sudo apt-get install php5-mysql
navigate to http://localhost:81/wp-admin/install.php
#/etc/nginx/nginx.conf keepalive_timeout 300;
# a small bash script that checks for all tables in a given database for MyMaria tables, alters/repairs them # MYSQL="/usr/bin/mysql" MYSQLR="/usr/bin/mysqlrepair" MYSQL_HOST="localhost" MYSQL_USER="root" MYSQL_PASSWD="your_password" MYSQL_SOCKET="/var/run/mysqld/mysqld.sock" MYSQLCONNECT="$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWD -h $MYSQL_HOST -S $MYSQL_SOCKET -A" MYSQLREPAIR="$MYSQLR -v -F -u$MYSQL_USER -p$MYSQL_PASSWD -B" echo "Checking DB " # Use MySQL 'SHOW DATABASES' DATABASES="`$MYSQLCONNECT --batch -N -e "show databases like 'your_blog_db'"`" echo "Checking for InnoDB Tables " # Loop through each instance of MySQL and check all databases in that instance for DATABASE in $DATABASES do TABLES="`$MYSQLCONNECT --batch -D $DATABASE -N -e "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='$DATABASE' AND TABLE_TYPE='BASE TABLE' AND ENGINE IN ('InnoDB')"`" for TABLE in $TABLES do echo "Altering Table : $TABLE" ALTERTABLES="`$MYSQLCONNECT --batch -D $DATABASE -N -e "ALTER TABLE $TABLE ENGINE=Maria"`" echo "Repairing Table: $TABLE" REPAIR_TABLE=`$MYSQLREPAIR $DATABASE --tables $TABLE` done done
#/etc/mysql/my.cnf skip-innodb default_storage_engine = Maria # My installation of MariaDB on Ubuntu came like this by default. Make sure you don't switch # Traditional mode ON/OFF if you don't know the consequences. sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
There are a few modules in WordPress (mostly based around the comment system and plugins such as Akismet) that use the client remote IP address. Unfortunately, with our current configuration $_SERVER['REMOTE_ADDR'] will always return 127.0.0.1.
In order to fix this we just need to set $_SERVER['REMOTE_ADDR'] to the value of the X-Forwarded-For header that we set in our Nginx config. You can do this by adding the following code to the top of your wp-config.php.
if ( ! empty( $_SERVER['X-Forwarded-For'] ) && $_SERVER["REMOTE_ADDR"] == "10.10.0.1") { $forwardip = explode(",", $_SERVER['X-Forwarded-For']); $_SERVER['REMOTE_ADDR'] = $forwardip[0];}
Navigate to http://localhost:81/wp-admin/options-general.php and set Wordpress Address and *Site Address" to http://localhost:80. This is because Wordpress does a lot of redirects for canonical URL and you will see a lot of localhost:81 based requests if you dont.