Installing WordPress with NGINX web server on Debian Operating System on Rackspace Cloud Server demands some guide vs Apache2.0. Here is step by step guide. The reason why installing WordPress with NGINX web server on Debian Operating System on Rackspace Cloud Server will require additional help even for the advanced users has multiple reasons – no, managed Rackspace Cloud Server now actually supports NGINX. That reason to guide has been obsolete now. Among various reasons, most common reason is – frankly we are more used with Apache Web Server than NGINX web server. There are many styles of installation and optimization.
Installing WordPress With NGINX on Debian : Previous Guides and More Resources
Those who are fully new, please install and play either with a mock setup or with VirtualBox on your Mac or PC. Even if you are using Debian OS on PC, do not directly do the trial and errors. May be, you are actually shifting WordPress from Apache to nginx Web Server. May be, you are going to install WordPress with PostgreSQL. Actually we have discussed before on how to install nginx on Rackspace Cloud Server with Centmin Mod Nginx Auto Installer easily. There was another guide on installing Nginx with PHP5, MySQL on Rackspace Cloud Server.
With time, we need to update the guides as the packages changes, Rackspace specially upgrades their available services.
---
Steps for Installing WordPress With NGINX on Debian on Rackspace Cloud Server
To import the MySQL dump, in case you are shifting, you can run rsync
to sync between the two servers. We however is describing the steps in this guide for installing WordPress with NGINX on Debian on Rackspace Cloud Server for a fresh copy, not transfer case.
We will suggest to create an user :
1 2 3 4 5 6 | # henceforth, hash is used to indicate our comment # line with hash are not commands & lines without hash are single commands. # you can combine two commands with && # we use hash like commenting out, it is easy to create bash scripts for the advanced users useradd -m <username> passwd <username> |
Routine work is to run three commands :
1 2 3 | apt-get update apt-get dist-upgrade reboot |
You will SSH with user account and do the works. This is safer method. Actually you can toggle permission to limit access :
1 2 3 4 5 6 7 | nano /etc/ssh/sshd_conf # alternatively open with vim vi /etc/ssh/sshd_conf # find the line PermitRootLogin yes # change it to PermitRootLogin no |
In this way, you can use su -
to run commands with privilege only with password. UFW (Uncomplicated Firewall) is very nice to setup Firewall with few commands :
1 2 3 4 5 6 7 | # install the package apt-get install ufw # let us configure ufw allow www ufw allow ssh ufw default deny ufw enable |
This is basic setup. It is, probably safe to harden nginx from this Gist. As everyone knows, we need to add backports/dot deb on Debian for getting updated nginx packages :
1 2 3 4 5 6 7 | echo 'deb http://backports.debian.org/debian-backports squeeze-backports main' >> /etc/apt/sources.list.d/backports.list echo 'deb http://packages.dotdeb.org stable all' >> /etc/apt/sources.list.d/DotDeb.list echo 'deb-src http://packages.dotdeb.org stable all' >> /etc/apt/sources.list.d/DotDeb.list wget http://www.dotdeb.org/dotdeb.gpg cat dotdeb.gpg | sudo apt-key add - rm dotdeb.gpg sudo apt-get update |
The echo method is better than editing /etc/apt/sources.list.d file. Kevin Carter (Rackspace) initially wrote it and an user named Nick fixed it. It is quite good idea to use echo like we do on OS X. For this kind of efficiency, honestly we suggest for managed Rackspace. Understand it – to fix your broken bone, it will take 10 minutes for me but fixing server stuff will demand 30 minutes. Despite I am using UNIX for ~20 years, even before I entered Medical School. Regular exposure makes someone better in prototype work. What so ever, install nginx :
1 | apt-get install nginx-full |
Now edit the configuration file :
1 | nano /etc/nginx/nginx.conf |
Another gist is here to check the basic configuration.
1 2 3 4 5 6 7 | # multistep commands mkdir -p /var/www/domain/httpdocs mkdir /var/www/domain/logs chown -R www-data:www-data /var/www/ ln -s /etc/nginx/sites-available/sitename /etc/nginx/sites-enabled/sitename # sitename can be sitename.tld, sitename.conf etc. Restart. service nginx restart |
That file, at minimum should have this prototype configuration.
You must edit your Domain™s DNS records and point the A records to your server™s IP address to make it working. After propagation, browser can open the sites / contents located at var/www/domain/httpdocs
.
We need to install MySQL and other stuffs :
1 2 | apt-get install mysql-server-5.5 apt-get install php5-fpm php5-mysql php5-apc php5-xsl php5-xmlrpc php5-sqlite php5-curl php5-gd php5-tidy |
We need now to create our WordPress vhost config, in example case it is /etc/nginx/sites-available/sitename ” and edit as we described above as you can host multiple websites. Now create a database :
1 2 3 4 5 | mysql -u root -p CREATE DATABASE namedb; GRANT ALL PRIVILEGES ON namedb.* TO "namedb_user_name"@"localhost" IDENTIFIED BY "password"; FLUSH PRIVILEGES; EXIT |
Depending on number of sites, location will vary, go to :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | cd /etc/nginx/sites-available/sitename wget http://wordpress.org/latest.tar.gz tar -xzvf latest.tar.gz cd wordpress mv * . # above command might need double dot instead of single for linux cd .. rm -r wordpress # Edit wp-config file nano wp-config-sample.php # give the details # save as wp-config.php # follow normal wordpress installation # https://codex.wordpress.org/Installing_WordPress |
For W3 Super Cache, we need to install Varnish :
1 2 3 4 5 | curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add - echo "deb http://repo.varnish-cache.org/debian/ <version-name> varnish-3.0" >> /etc/apt/sources.list apt-get update apt-get install varnish # replace version-name with wheezy or what you are using |
Polishing varnish is important! But we will not go in to details here, just the minimum :
1 2 3 4 5 6 7 8 | sudo nano /etc/default/varnish # configaration file should match DAEMON_OPTS="-a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m" |
After saving, exit and edit this file :
1 | sudo nano /etc/varnish/default.vcl |
It should look like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | backend default { .host = "127.0.0.1"; .port = "8080"; } sub vcl_recv { if (!(req.url ~ "wp-(login|admin)")) { unset req.http.cookie; } } sub vcl_fetch { if (!(req.url ~ "wp-(login|admin)")) { unset beresp.http.set-cookie; } } |
We will polish varnish, apc; but that is another longer story. This is the minimum setup for WordPress with NGNIX.
Tagged With compoundpv5 , expect86y , followcz8 , honorhjv , pictured8s1