//Englisch-English//
Dear EPVP,
its really important for a good running project, to have a fast operating and stable website, but what to do if you have problems with memory leaks and high CPU usage ?
Maybe you should think what kind of software you´re using there´re different webserver´s available.
Now lets begin with the tutorial, as you can probably tell from the post title im going to use Nginx and show how you can configure it with PHP,Mysql,PHPmyadmin and varnish.
What we need:
Debian 6 or 7
Time + Patience + Basic knowledge in linux operating systems.
Information
You can search a word in nano with STRG+W Save the file with STRG+O and close nano with STRG+X.
Step1 Preparations for the NGINX installation:
Run the following commands to get the latest version of Nginx:
Debian 6+7 retrieve the signing key.
Debian7 add the Repo:
Debian6 add the Repo:
Now run
and the latest version of nginx is available.
Step 2 Install Nginx:
One simple command is enough:
Now create the folder /var/www and set the permissions for nginx:
Step 3 Configure Nginx after the installation Attention: All configs were tested under Debian7 running Nginx-Version 1.4.2:
The Nginx configuration files are stored in /etc/nginx.
Edit /etc/nginx/nginx.conf
Change the following options:
Aditionally add the following settings
Remove the following settings if not done yet(put an # in front of it):
Edit /etc/nginx/conf.d/default.conf
[SAMPLE CONFIG FOR IPV4+6 ]
Step 4 Install php5-fpm and some php-extensions
Run:
Schritt 4.1 Edit the php-fpm config
Files are stored in: /etc/php5/fpm/
Edit /etc/php5/fpm/php.ini
Add the following at the end of the file:
Edit /etc/php5/fpm/pool.d/www.conf
Replace
or
with
Replace
with
Step 5 install the Varnish Cacheserver:
Step 5.1 Varnish configuration:
Files are stored in /etc/varnish
Edit /etc/varnish/default.vcl

[SAMPLE CONFIG FOR WORDPRESS]
Edit the /etc/default/varnish Config:
Change the following section:
to
Step 6 restart everything and make sure it works
Step 7 Mysql:
Run and follow the instructions on screen:
Thats it, easy wasnt it ^^.
Step 8 install PHPmyadmin:
Run the following commands to retrieve the latest phpmyadmin package and move them to /usr/share/phpmyadmin.
Now we create the config /usr/share/phpmyadmin/config.inc.php
You can take the sample below, dont forget to change everything marked with #Please change me
Ones more please change everything marked with #Please change me
Now we create the database and the controluser for phpmyadmin.
PLEASE REPLACE yourpassword with the same password you used in the config.inc.php.
Thats it we´re done i hope everything is working if not check the troubleshooting guide below!
Dont forget to restart everything:
its really important for a good running project, to have a fast operating and stable website, but what to do if you have problems with memory leaks and high CPU usage ?
Maybe you should think what kind of software you´re using there´re different webserver´s available.
- Apache2 (Great and reliable but slow with many users)
- Nginx (pronounced Engine-X) fast and small webserver based on events gives good speed and has a low cpu and memory consumption.
Now lets begin with the tutorial, as you can probably tell from the post title im going to use Nginx and show how you can configure it with PHP,Mysql,PHPmyadmin and varnish.
What we need:
Debian 6 or 7
Time + Patience + Basic knowledge in linux operating systems.
Information
You can search a word in nano with STRG+W Save the file with STRG+O and close nano with STRG+X.
Step1 Preparations for the NGINX installation:
Run the following commands to get the latest version of Nginx:
Debian 6+7 retrieve the signing key.
Code:
cd /tmp/ wget http://nginx.org/keys/nginx_signing.key apt-key add /tmp/nginx_signing.key
Code:
echo "deb http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list echo "deb-src http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list
Code:
echo "deb http://nginx.org/packages/debian/ squeeze nginx" >> /etc/apt/sources.list echo "deb-src http://nginx.org/packages/debian/ squeeze nginx" >> /etc/apt/sources.list
Code:
apt-get update
Step 2 Install Nginx:
One simple command is enough:
Code:
apt-get install nginx
Code:
mkdir -p /var/www/ chown nginx:nginx /var/www/ chmod -R 775 /var/www
The Nginx configuration files are stored in /etc/nginx.
Edit /etc/nginx/nginx.conf
Code:
nano /etc/nginx/nginx.conf
Code:
worker_processes Ammount of CPU Cores; In the event Section: worker_connections 2048; In the http section: port_in_redirect off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 10; index index.html index.htm index.php;
Code:
gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Code:
access_log error_log
Code:
nano /etc/nginx/conf.d/default.conf
Code:
#DEFAULT Server for all requests not defined below
server {
root /var/www/null; # PLEASE CHANGE THE FOLDER
listen 8080;
listen [::]:8080 ipv6only=on default_server;
}
server {
## PUT YOUR DOMAINS HERE.
server_name example.com www.example.com; # PLEASE CHANGE
listen 8080;
listen [::]:8080;
root /var/www/your_subfolder/; # PLEASE CHANGE
location ~ \.php$ {
try_files $uri =404;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
}
Run:
Code:
apt-get install php5-fpm php-pear php5-common php5-mysql php-apc php5-gd php5-curl php5-mcrypt
Files are stored in: /etc/php5/fpm/
Edit /etc/php5/fpm/php.ini
Code:
nano /etc/php5/fpm/php.ini
Code:
[apc] apc.write_lock = 1 apc.slam_defense = 0
Code:
nano /etc/php5/fpm/pool.d/www.conf
Code:
listen = 127.0.0.1:9000
Code:
listen = /var/run/XXXX
Code:
listen = /dev/shm/php-fpm-www.sock listen.owner = nginx listen.group = nginx listen.mode = 0660
Code:
user = www-data group = www-data
Code:
user = nginx group = nginx
Code:
apt-get install varnish
Files are stored in /etc/varnish
Edit /etc/varnish/default.vcl
Code:
nano /etc/varnish/default.vcl

[SAMPLE CONFIG FOR WORDPRESS]
Code:
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
.max_connections = 800;
}
acl purge {
"localhost";
}
sub vcl_recv {
set req.grace = 2m;
# Set X-Forwarded-For header for logging in nginx
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
# Remove has_js and CloudFlare/Google Analytics __* cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
# Remove a ";" prefix, if present.
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
# Either the admin pages or the login
if (req.url ~ "/wp-(login|admin|cron)") {
# Don't cache, pass to backend
return (pass);
}
# Remove the wp-settings-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");
# Remove the wp-settings-time-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");
# Remove the wp test cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");
# Static content unique to the theme can be cached (so no user uploaded images)
# The reason I don't take the wp-content/uploads is because of cache size on bigger blogs
# that would fill up with all those files getting pushed into cache
if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
unset req.http.cookie;
}
# Even if no cookies are present, I don't want my "uploads" to be cached due to their potential size
if (req.url ~ "/wp-content/uploads/") {
return (pass);
}
# Check the cookies for wordpress-specific items
if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
# A wordpress specific cookie has been set
return (pass);
}
# allow PURGE from localhost
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
# Force lookup if the request is a no-cache request from the client
if (req.http.Cache-Control ~ "no-cache") {
return (pass);
}
# Try a cache-lookup
return (lookup);
}
sub vcl_fetch {
#set obj.grace = 5m;
set beresp.grace = 2m;
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
Code:
nano /etc/default/varnish
Code:
DAEMON_OPTS="-a :6081 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
Code:
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
Code:
service php5-fpm restart service nginx restart service varnish restart
Run and follow the instructions on screen:
Code:
apt-get install mysql-server
Thats it, easy wasnt it ^^.
Step 8 install PHPmyadmin:
Run the following commands to retrieve the latest phpmyadmin package and move them to /usr/share/phpmyadmin.
Code:
wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.4.1/phpMyAdmin-4.0.4.1-all-languages.tar.gz tar -xvf phpMyAdmin-4.0.4.1-all-languages.tar.gz mv phpMyAdmin-4.0.4.1-all-languages /usr/share/phpmyadmin
Code:
nano /usr/share/phpmyadmin/config.inc.php
PHP Code:
<?php
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <http://docs.phpmyadmin.net/>.
*
* @package PhpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'testetrertsertsdf213123123'; #Please change me
/*
* Servers configuration
*/
$i = 0;
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
/*
* phpMyAdmin configuration storage settings.
*/
/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'localhost';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'yourpassword'; # please change
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
?>
Now we create the database and the controluser for phpmyadmin.
Code:
mysql -u root -p Create Database phpmyadmin; Use phpmyadmin; source /usr/share/phpmyadmin/examples/create_tables.sql;
Code:
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT SELECT (
Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
Execute_priv, Repl_slave_priv, Repl_client_priv
) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
ON mysql.tables_priv TO 'pma'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';
Dont forget to restart everything:
Code:
service php5-fpm restart service nginx restart service varnish restart
//GERMAN-DEUTSCH//
Hallo EPVP,
da es für einen Server essentiell ist eine schnelle und ausfallsichere Homepage zu besitzen sollte bekannt sein, aber was tun wenn man mit ausfällen und hoher CPU/Memory Auslastung zu kämpfen hat?
Man sollte sich mal Gedanken machen welche Software man einsetzt, hier mal eine kleine Auflistung verschiedener WebServer.
Apache 2
Nginx (Engine X)
Lighttpd
Alle diese Server haben ihre Schwächen und Stärken, zu den Stärken meines Favoriten Nginx (Engine X ausgesprochen) gehören unteranderem die geringe CPU und RAM Auslastung und die Geschwindigkeit aufgrund Event basierter Programmierung.
Nun zum eigentlichen Tutorial:
Was wird benötigt:
Debian 6 oder 7
Zeit + Geduld + Verständnis für die meisten Befehle
Grundkentnisse in Linux Umgebungen
Tipps:
In nano lässt sich mit STRG+W nach einem Begriff suchen STRG+O speichert das Dokument und STRG+X schließt den Editor.
Schritt 1 Vorbereitungen für die NGINX Installation:
Führt bitte die folgenden Befehle aus um die neuste Version von NGINX auf euer System zu bringen.
Als erstes müsst ihr eine neue Paketquelle zu Debian hinzufügen um NGINX von der Offiziellen REPO zu beziehen.
DEBIAN 6+7 beziehen des Signing Key´s
Debian7 hinzufügen der Repo:
Debian6 hinzufügen der Repo:
Jetzt noch ein
und die neuste Version von Nginx steht zur Verfügung.
Schritt2 Installieren von Nginx:
Ein einfacher Befehl reicht für diesen Schritt.
Jetzt erstellen wir noch einen neuen Ordner unter /var/www und geben nginx die Rechte mit diesem zu Arbeiten:
Schritt 3 Konfigurieren von Nginx nach der Installation ACHTUNG ALLE CONFIGS WURDEN MIT NGINX-Version 1.4.2 unter Debian7 getestet:
Die Nginx Dateien befinden sich in /etc/nginx, hier werden wir jetzt auch die ersten Änderungen vornehmen.
Bearbeiten der /etc/nginx/nginx.conf
Folgende Einstellungen werden hier angepasst:
Folgende Einstellungen werden aktiviert oder hinzugefügt (# vorm Befehl entfernen)
Folgende Einstellungen werden auskommentiert(# vor den Befehl) sofern nicht schon deaktiviert:
Bearbeiten der /etc/nginx/conf.d/default.conf
[BEISPIEL CONFIG FÜR IPV4+6 ]
Schritt 4 Installation von php5-fpm und php Erweiterungen
Schritt 4.1 Bearbeiten der Konfiguration von php-fpm
Die Dateien liegen unter /etc/php5/fpm/
Bearbeiten der /etc/php5/fpm/php.ini
Bitte ganz am Ende folgendes einfügen:
Bearbeiten der /etc/php5/fpm/pool.d/www.conf
Ersetzt
mit
und
mit
Schritt 5 Varnish installieren:
Schritt 5.1 Varnish Konfigurieren:
Die Dateien liegen in /etc/varnish
Bearbeiten der /etc/varnish/default.vcl

[BEISPIEL KONFIG FÜR WORDPRESS]
Bearbeiten der /etc/default/varnish Konfigurationsdatei:
Ändert den folgenden Abschnitt:
zu
Schritt 6 alles neustarten und sichergehen das alles funktioniert.
Schritt 7 Mysql:
ausführen und den Anweisungen folgen.
Das wars.
Schritt 8 PHPmyadmin installieren:
Folgende Befehle ausführen:
Jetzt erstellen wir die /usr/share/phpmyadmin/config.inc.php
und fügen folgendes ein:
Bitte alle Felder bearbeiten die mit #please change gekennzeichnet sind
Jetzt erstellen wir noch die Datenbank für phpmyadmin und den controluser.
BITTE yourpassword mit eurem sicheren Passwort ersetzen, das ihr in der Config angegeben habt.
Ich wünsche euch viel Spaß mit dem Endprodukt dieses Tutorials sollte es Fragen und Probleme geben meldet euch bitte.
da es für einen Server essentiell ist eine schnelle und ausfallsichere Homepage zu besitzen sollte bekannt sein, aber was tun wenn man mit ausfällen und hoher CPU/Memory Auslastung zu kämpfen hat?
Man sollte sich mal Gedanken machen welche Software man einsetzt, hier mal eine kleine Auflistung verschiedener WebServer.
Apache 2
Nginx (Engine X)
Lighttpd
Alle diese Server haben ihre Schwächen und Stärken, zu den Stärken meines Favoriten Nginx (Engine X ausgesprochen) gehören unteranderem die geringe CPU und RAM Auslastung und die Geschwindigkeit aufgrund Event basierter Programmierung.
Nun zum eigentlichen Tutorial:
Was wird benötigt:
Debian 6 oder 7
Zeit + Geduld + Verständnis für die meisten Befehle
Grundkentnisse in Linux Umgebungen
Tipps:
In nano lässt sich mit STRG+W nach einem Begriff suchen STRG+O speichert das Dokument und STRG+X schließt den Editor.
Schritt 1 Vorbereitungen für die NGINX Installation:
Führt bitte die folgenden Befehle aus um die neuste Version von NGINX auf euer System zu bringen.
Als erstes müsst ihr eine neue Paketquelle zu Debian hinzufügen um NGINX von der Offiziellen REPO zu beziehen.
DEBIAN 6+7 beziehen des Signing Key´s
Code:
cd /tmp/ wget http://nginx.org/keys/nginx_signing.key apt-key add /tmp/nginx_signing.key
Debian7 hinzufügen der Repo:
Code:
echo "deb http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list echo "deb-src http://nginx.org/packages/debian/ wheezy nginx" >> /etc/apt/sources.list
Code:
echo "deb http://nginx.org/packages/debian/ squeeze nginx" >> /etc/apt/sources.list echo "deb-src http://nginx.org/packages/debian/ squeeze nginx" >> /etc/apt/sources.list
Jetzt noch ein
Code:
apt-get update
Schritt2 Installieren von Nginx:
Ein einfacher Befehl reicht für diesen Schritt.
Code:
apt-get install nginx
Code:
mkdir -p /var/www/ chown nginx:nginx /var/www/ chmod -R 775 /var/www
Schritt 3 Konfigurieren von Nginx nach der Installation ACHTUNG ALLE CONFIGS WURDEN MIT NGINX-Version 1.4.2 unter Debian7 getestet:
Die Nginx Dateien befinden sich in /etc/nginx, hier werden wir jetzt auch die ersten Änderungen vornehmen.
Bearbeiten der /etc/nginx/nginx.conf
Code:
nano /etc/nginx/nginx.conf
Code:
worker_processes NUMMER_DER_CPU_KERNE; UNTER EVENTS: worker_connections 2048; UNTER HTTP: port_in_redirect off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 10; index index.html index.htm index.php;
Code:
gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Code:
access_log error_log
Code:
nano /etc/nginx/conf.d/default.conf
Code:
#STANDARD Server FueR ALLE REQUESTS DIE NICHT ZUGEORDNET SIND
server {
root /var/www/null; # Bitte aendern hier landen alle Anfragen die nicht definiert sind
listen 8080;
listen [::]:8080 ipv6only=on default_server;
}
server {
## EURE DOMAINS HIER.
server_name example.com; # Bitte ändern
listen 8080;
listen [::]:8080;
root /var/www/EUER_UNTERORDNER/; # Bitte aendern
location ~ \.php$ {
try_files $uri =404;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
}
Schritt 4 Installation von php5-fpm und php Erweiterungen
Code:
apt-get install php5-fpm php-pear php5-common php5-mysql php-apc php5-gd php5-curl php5-mcrypt
Die Dateien liegen unter /etc/php5/fpm/
Bearbeiten der /etc/php5/fpm/php.ini
Code:
nano /etc/php5/fpm/php.ini
Code:
[apc] apc.write_lock = 1 apc.slam_defense = 0
Code:
nano /etc/php5/fpm/pool.d/www.conf
Code:
listen = 127.0.0.1:9000
Code:
listen = /dev/shm/php-fpm-www.sock listen.owner = nginx listen.group = nginx listen.mode = 0660
Code:
user = www-data group = www-data
Code:
user = nginx group = nginx
Code:
apt-get install varnish
Die Dateien liegen in /etc/varnish
Bearbeiten der /etc/varnish/default.vcl
Code:
nano /etc/varnish/default.vcl

[BEISPIEL KONFIG FÜR WORDPRESS]
Code:
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
.max_connections = 800;
}
acl purge {
"localhost";
}
sub vcl_recv {
set req.grace = 2m;
# Set X-Forwarded-For header for logging in nginx
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
# Remove has_js and CloudFlare/Google Analytics __* cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js)=[^;]*", "");
# Remove a ";" prefix, if present.
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
# Either the admin pages or the login
if (req.url ~ "/wp-(login|admin|cron)") {
# Don't cache, pass to backend
return (pass);
}
# Remove the wp-settings-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", "");
# Remove the wp-settings-time-1 cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", "");
# Remove the wp test cookie
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", "");
# Static content unique to the theme can be cached (so no user uploaded images)
# The reason I don't take the wp-content/uploads is because of cache size on bigger blogs
# that would fill up with all those files getting pushed into cache
if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") {
unset req.http.cookie;
}
# Even if no cookies are present, I don't want my "uploads" to be cached due to their potential size
if (req.url ~ "/wp-content/uploads/") {
return (pass);
}
# Check the cookies for wordpress-specific items
if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") {
# A wordpress specific cookie has been set
return (pass);
}
# allow PURGE from localhost
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
# Force lookup if the request is a no-cache request from the client
if (req.http.Cache-Control ~ "no-cache") {
return (pass);
}
# Try a cache-lookup
return (lookup);
}
sub vcl_fetch {
#set obj.grace = 5m;
set beresp.grace = 2m;
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
Code:
nano /etc/default/varnish
Code:
DAEMON_OPTS="-a :6081 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
Code:
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
Schritt 6 alles neustarten und sichergehen das alles funktioniert.
Code:
service php5-fpm restart service nginx restart service varnish restart
Code:
apt-get install mysql-server
Das wars.
Schritt 8 PHPmyadmin installieren:
Folgende Befehle ausführen:
Code:
wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.0.4.1/phpMyAdmin-4.0.4.1-all-languages.tar.gz tar -xvf phpMyAdmin-4.0.4.1-all-languages.tar.gz mv phpMyAdmin-4.0.4.1-all-languages /usr/share/phpmyadmin
Code:
nano /usr/share/phpmyadmin/config.inc.php
PHP Code:
<?php
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <http://docs.phpmyadmin.net/>.
*
* @package PhpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'asfd12312l123#-y-#-+##-+#-#-23423'; # please change required for cookie auth
/*
* Servers configuration
*/
$i = 0;
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Servers'][$i]['hide_db'] = 'information_schema';
/*
* phpMyAdmin configuration storage settings.
*/
/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'localhost';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'yourpassword'; # please change
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
?>
Jetzt erstellen wir noch die Datenbank für phpmyadmin und den controluser.
Code:
mysql -u root -p Create Database phpmyadmin; Use phpmyadmin; source /usr/share/phpmyadmin/examples/create_tables.sql;
Code:
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT SELECT (
Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
Execute_priv, Repl_slave_priv, Repl_client_priv
) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
ON mysql.tables_priv TO 'pma'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'pma'@'localhost';
Troubleshooting:
404 Not found or 403 Forbidden:
1. Are the defined folders in the default.conf file correct and do they exist? ?
2.Perhaps there´s a permission problem run the chown and chmod commands again.
3.An empty folder triggers an 403 forbidden error.
2.Perhaps there´s a permission problem run the chown and chmod commands again.
3.An empty folder triggers an 403 forbidden error.
Code:
chown nginx:nginx /var/www/ chmod -R 775 /var/www
@AUTHOR: Martin B | MartPwnS.
@NOTE: Tutorial TESTED DATE: 21.07.2013 17:10






