How to set-up a VPS with nginx, PHP, mysql, phpMyAdmin, mail server, FTP, Webmin, Memcached and EAccelerator and then install WordPress
Here I explain how to set up a VPS with the features above and
install WordPress on Ubuntu 10.04 LTS. It is always best to use a LTS
(Long Term Support) version of Ubuntu since then you get security
updates for 5 years, instead of 18 months. I got my VPS from IntoVPS,
with 1024 MB of burstable RAM (512 MB guaranteed), 30GB disk space and
500GB monthly traffic for 10$/month. The steps I take here worked for me
on this server, but if you have any problems either leave a comment or
post in the forum.
1. Initial setup
First we have to get the server ready. I am assuming you have already logged in using PuTTY as root. First update the package repositary listing:
Now install any updates:
Just in case:
Now were ready to install nginx.
2. NGINX
nginx (pronounced “engine-x”) is a lightweight, fast and powerful HTTP server. More information here. If you are having second thoughts about switching to nginx, let´s put it this way: I still consider switching from Apache to nginx the best thing I´ve ever done to this VPS, and I can personally testify that WordPress, phpMyAdmin, Roundcube webmail and Simple Machines Forum work perfectly with nginx.
First we have to add the nginx repositary to the database, beacause at the time of writing the latest stable nginx is version 0.8.54 (Update: it is now 1.0.0), whereas the latest in the default Ubuntu repositary is 0.7. To add the repositary first we have to install python-software-properties:
Now add the repository:
Now update the database:
Now install nginx:
We’ll configure it, and set up PHP5, in the next section.
3. PHP
If your planning to just serve static content from your server, you can stop here, or go on to set up the mail server. But if you´re going to install WordPress (or an other PHP application) then we have to install PHP.
(Update: see an alternative (better) way of installing PHP here)
First we install the PHP CGI and other components we may need:
Now we have to create a PHP-FastCGI initialization script. Let´s first open the new file with nano:
Now paste the following code into the file (note: if you’re using PuTTY just copy this then right-click in the PuTTY window.) :
Things you may want to change:
Now start the script:
Now we have enable PHP in nginx. First open the config file:
Now make the following changes:
Your config file should now look like this:
Don’t forget to read the file to make shure everything is set up right.
Now restart nginx:
Now it´s time to create a test script:
Inside, insert the following:
And save the file. Now go to your-site.com/test.php in your web browser. You should see a page with your PHP configuration information. We are now ready to install MySQL!
4. MySQL
Type:
And follow the instructions that appear on-screen. Now restart the PHP server:
Now it´s time to install phpMyAdmin
5. phpMyAdmin
phpMyAdmin is a browser-based MySQL database manager writen in PHP. First let´s install it:
If the installer asks you what HTTP server to configure for, press enter without answering.
Now we have to be able to access phpMyAdmin through phpmyadmin.your-site.com. First create a new config file:
And inside insert the following (don´t forget the right-click method):
Change your-site.com on line 9 to your domain name. Don´t forget to set up the DNS record!!!
Now we have to enable this configuration using the following command:
Now restart nginx and your done. Go to phpmyadmin.your-site.com in your web-browser and login with the username and password you specified in the MySQL installer (not the phpMyAdmin one).
6. Email server
Now it´s time to set up a Mail Transport Agent (MTA), in this case, Postfix; and a POP3/IMAP server, Dovecot, so we can read the mail. (Note: If your planning to use Google Apps for email, or not use your own email at all, you can skip this step.
First let´s install Postfix:
Follow the insructions on-screen until the installation completes. We´ll configure Postfix later. Now let´s install Dovecot:
Open the config file:
Find the following settings (using the CTRL+W function) and make shure they are set as below (uncomment if necesary):
Now replace this:
With this:
And just before that line add:
Now enter the Postfix config file:
And insert at the end:
Replacing your-site.com with your domain name.
Now add a new user to recieve and send email (If new user is joe then email address will be joe@your-site.com. Create as many users as you want):
Now restart all components of the mail server:
Now you can access your email through your email client, or through
any webmail package. I recomend Roundcube webmail, since it is easy to
set up and use, stylish and works great with nginx!
7. FTP server
I use vsftpd (Very Secure File Transfer Protocol Daemon) beacause it´s lightning fast and very easy to set up. First let´s install it:
Now let´s edit the config file:
Replace the entire contents with:
Things to change:
You can now login to your server using FTP (using the user account you created before. Root logins will not work.)
8. Webmin
Webmin is a server control panel similar to cPanel and Plesk, but it is free. First get the download path for the latest .tar.gz version here. Then download and install it on your server:
After setup is complete go to your-site.com:10000 and login with the username and password you specified during the installation.
9.Things to set-up before continuing
Now is a good time to do certain tasks that should be performed.
First, I recommend, as a security precaution, to change the SSH port using Webmin (Servers > SSH server > Networking). Don´t forget to click apply changes after changing the port number, or to update the port number in the PuTTY configuration window.
We also have to add the user you use to make FTP connections to the www-data group, so that there isn´t any permission errors when we install WordPress. First go to System > Users and Groups and select the user account you use to make your FTP connections. Go to the Group membership section and set Primary Group to www-data. Now go to Secondary groups and add the group with the same name as the user account. Also add the sudo group if you want this user account to be able to use the sudo command. Now set Change group ID on files? to All files.
Now click save. Do this to all user accounts you use to upload files
via FTP. So now nginx has group access to your users files (In other
words, permission 774 means full permissions for owner, full permissions for nginx (and therefore WordPress, etc…)
and read permissions for everybody else. We do this so the server can
modify files when we use things like WordPress. Now go to the SSH
terminal and type:1. Initial setup
First we have to get the server ready. I am assuming you have already logged in using PuTTY as root. First update the package repositary listing:
apt-get update
Now install any updates:
apt-get upgrade
Just in case:
apt-get install wget make
Now were ready to install nginx.
2. NGINX
nginx (pronounced “engine-x”) is a lightweight, fast and powerful HTTP server. More information here. If you are having second thoughts about switching to nginx, let´s put it this way: I still consider switching from Apache to nginx the best thing I´ve ever done to this VPS, and I can personally testify that WordPress, phpMyAdmin, Roundcube webmail and Simple Machines Forum work perfectly with nginx.
First we have to add the nginx repositary to the database, beacause at the time of writing the latest stable nginx is version 0.8.54 (Update: it is now 1.0.0), whereas the latest in the default Ubuntu repositary is 0.7. To add the repositary first we have to install python-software-properties:
apt-get install python-software-properties
Now add the repository:
add-apt-repository ppa:nginx/stable
Now update the database:
apt-get update
Now install nginx:
apt-get install nginx
We’ll configure it, and set up PHP5, in the next section.
3. PHP
If your planning to just serve static content from your server, you can stop here, or go on to set up the mail server. But if you´re going to install WordPress (or an other PHP application) then we have to install PHP.
(Update: see an alternative (better) way of installing PHP here)
First we install the PHP CGI and other components we may need:
apt-get install php5 php5-cgi php5-sqlite php5-tidy php5-xmlrpc php5-xs php5-dev
Now we have to create a PHP-FastCGI initialization script. Let´s first open the new file with nano:
nano /etc/init.d/php-fastcgi
Now paste the following code into the file (note: if you’re using PuTTY just copy this then right-click in the PuTTY window.) :
-
#!/bin/bash
-
BIND=127.0.0.1:9000
-
USER=www-data
-
PHP_FCGI_CHILDREN=6
-
PHP_FCGI_MAX_REQUESTS=1000
-
PHP_CGI=/usr/bin/php-cgi
-
PHP_CGI_NAME=`basename $PHP_CGI`
-
PHP_CGI_ARGS=“- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND”
-
RETVAL=0
-
start() {
-
echo -n “Starting PHP FastCGI: “
-
start-stop-daemon –quiet –start –background –chuid “$USER” –exec /usr/bin/env — $PHP_CGI_ARGS
-
RETVAL=$?
-
echo “$PHP_CGI_NAME.”
-
}
-
stop() {
-
echo -n “Stopping PHP FastCGI: “
-
killall -q -w -u $USER $PHP_CGI
-
RETVAL=$?
-
echo “$PHP_CGI_NAME.”
-
}
-
case “$1″ in
-
start)
-
start
-
;;
-
stop)
-
stop
-
;;
-
restart)
-
stop
-
start
-
;;
-
*)
-
echo “Usage: php-fastcgi {start|stop|restart}”
-
exit 1
-
;;
-
esac
-
exit $RETVAL
- PHP_FCGI_CHILDREN on line 4: This is the number of worker processes that FastCGI spawns to handle PHP requests. The more connections per second your site recieves, the higher you should set this setting. Keep this in mind: Connections per second * Seconds it takes to generate the page = PHP_FCGI_CHILDREN. If you are running out of memory decrease this value.
- PHP_FCGI_MAX_REQUESTS on line 5: This is the number of requests before the worker proces(es) are respawned (restarted). If you are having any problems with memory leaks, blank pages, etc., try decreasing this to 500.
chmod +x /etc/init.d/php-fastcgi
Now start the script:
/etc/init.d/php-fastcgi start
Now we have enable PHP in nginx. First open the config file:
nano /etc/nginx/sites-available/default
Now make the following changes:
- On line 25, add index.php just before the semi-colon (;).
- Change localhost on line 28 to your domain. If you do not have a domain name leave it as it is.
- Uncomment the following lines:
-
location ~ .php$ {
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
include fastcgi_params;
-
}
-
server {
-
#listen 80; ## listen for ipv4; this line is default and implied
-
#listen [::]:80 default ipv6only=on; ## listen for ipv6
-
# Document root:
-
root /usr/share/nginx/www;
-
index index.html index.htm index.php;
-
# Make site accessible from your-site.com and www.your-site.com (change to your domain name)
-
server_name your-site.com www.your-site.com;
-
location / {
-
# First attempt to serve request as file, then
-
# as directory, then fall back to index.html
-
try_files $uri $uri/ /index.html;
-
}
-
location /doc {
-
root /usr/share;
-
autoindex on;
-
allow 127.0.0.1;
-
deny all;
-
}
-
location /images {
-
root /usr/share;
-
autoindex off;
-
}
-
#error_page 404 /404.html;
-
# redirect server error pages to the static page /50x.html
-
#
-
#error_page 500 502 503 504 /50x.html;
-
#location = /50x.html {
-
# root /usr/share/nginx/www;
-
#}
-
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
-
#
-
#location ~ .php$ {
-
# proxy_pass http://127.0.0.1;
-
#}
-
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-
#
-
location ~ .php$ {
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
include fastcgi_params;
-
}
-
# deny access to .htaccess files, if Apache’s document root
-
# concurs with nginx’s one
-
#
-
#location ~ /.ht {
-
#deny all;
-
#}
-
}
Now restart nginx:
/etc/init.d/nginx restart
Now it´s time to create a test script:
nano /usr/share/nginx/www/test.php
Inside, insert the following:
<?php phpinfo() ?>
And save the file. Now go to your-site.com/test.php in your web browser. You should see a page with your PHP configuration information. We are now ready to install MySQL!
4. MySQL
Type:
apt-get install mysql-server mysql-client php5-mysql
And follow the instructions that appear on-screen. Now restart the PHP server:
/etc/init.d/php-fastcgi restart
Now it´s time to install phpMyAdmin
5. phpMyAdmin
phpMyAdmin is a browser-based MySQL database manager writen in PHP. First let´s install it:
apt-get install phpmyadmin
If the installer asks you what HTTP server to configure for, press enter without answering.
Now we have to be able to access phpMyAdmin through phpmyadmin.your-site.com. First create a new config file:
nano /etc/nginx/sites-available/phpmyadmin
And inside insert the following (don´t forget the right-click method):
-
server {
-
#listen 80; ## listen for ipv4; this line is default and implied
-
#listen [::]:80 default ipv6only=on; ## listen for ipv6
-
root /usr/share/phpmyadmin;
-
index index.php index.html index.htm;
-
# Make site accessible from http://localhost/
-
server_name phpmyadmin.your-site.com;
-
location / {
-
# First attempt to serve request as file, then
-
# as directory, then fall back to index.html
-
try_files $uri $uri/ /index.html;
-
}
-
location /doc {
-
root /usr/share;
-
autoindex on;
-
allow 127.0.0.1;
-
deny all;
-
}
-
location /images {
-
root /usr/share;
-
autoindex off;
-
}
-
#error_page 404 /404.html;
-
# redirect server error pages to the static page /50x.html
-
#
-
#error_page 500 502 503 504 /50x.html;
-
#location = /50x.html {
-
# root /usr/share/nginx/www;
-
#}
-
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
-
#
-
#location ~ .php$ {
-
# proxy_pass http://127.0.0.1;
-
#}
-
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-
#
-
location ~ .php$ {
-
fastcgi_pass 127.0.0.1:9000;
-
fastcgi_index index.php;
-
include fastcgi_params;
-
}
-
# deny access to .htaccess files, if Apache’s document root
-
# concurs with nginx’s one
-
#
-
#location ~ /.ht {
-
# deny all;
-
#}
-
}
Now we have to enable this configuration using the following command:
ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin
Now restart nginx and your done. Go to phpmyadmin.your-site.com in your web-browser and login with the username and password you specified in the MySQL installer (not the phpMyAdmin one).
6. Email server
Now it´s time to set up a Mail Transport Agent (MTA), in this case, Postfix; and a POP3/IMAP server, Dovecot, so we can read the mail. (Note: If your planning to use Google Apps for email, or not use your own email at all, you can skip this step.
First let´s install Postfix:
apt-get install postfix postfix-tls libsasl2-2 sasl2-bin libsasl2-modules popa3d
Follow the insructions on-screen until the installation completes. We´ll configure Postfix later. Now let´s install Dovecot:
apt-get install dovecot-imapd dovecot-pop3d dovecot-common
Open the config file:
nano /etc/dovecot/dovecot.conf
Find the following settings (using the CTRL+W function) and make shure they are set as below (uncomment if necesary):
protocols = imap pop3
ssl = no
mail_location = mbox:~/mail:INBOX=/var/mail/%u
pop3_uidl_format = %08Xu%08Xv
disable_plaintext_auth = no
Now replace this:
auth default {
With this:
auth default2 {
And just before that line add:
-
auth default {
-
mechanisms = plain login
-
passdb pam {
-
}
-
userdb passwd {
-
}
-
socket listen {
-
client {
-
path = /var/spool/postfix/private/auth
-
mode = 0660
-
user = postfix
-
group = postfix
-
}
-
}
-
}
nano /etc/postfix/main.cf
And insert at the end:
-
smtpd_sasl_auth_enable = yes
-
smtpd_sasl_local_domain = your-site.com
-
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
-
smtpd_sasl_security_options = noanonymous
Now add a new user to recieve and send email (If new user is joe then email address will be joe@your-site.com. Create as many users as you want):
adduser username
Now restart all components of the mail server:
-
/etc/init.d/saslauthd restart
-
/etc/init.d/postfix restart
-
/etc/init.d/dovecot restart
7. FTP server
I use vsftpd (Very Secure File Transfer Protocol Daemon) beacause it´s lightning fast and very easy to set up. First let´s install it:
apt-get install vsftpd
Now let´s edit the config file:
nano /etc/vsftpd.conf
Replace the entire contents with:
-
# Run standalone? vsftpd can run either from an inetd or as a standalone
-
# daemon started from an initscript.
-
listen=YES
-
#
-
# Run standalone with IPv6?
-
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
-
# instead of an IPv4 one. This parameter and the listen parameter are mutually
-
# exclusive.
-
#listen_ipv6=YES
-
#
-
# Allow anonymous FTP? (Disabled by default)
-
anonymous_enable=NO
-
#
-
# Uncomment this to allow local users to log in.
-
local_enable=YES
-
#
-
# Uncomment this to enable any form of FTP write command.
-
write_enable=YES
-
#
-
# Default umask for local users is 077. You may wish to change this to 022,
-
# if your users expect that (022 is used by most other ftpd’s)
-
#local_umask=022
-
#
-
# Uncomment this to allow the anonymous FTP user to upload files. This only
-
# has an effect if the above global write enable is activated. Also, you will
-
# obviously need to create a directory writable by the FTP user.
-
#anon_upload_enable=YES
-
#
-
# Uncomment this if you want the anonymous FTP user to be able to create
-
# new directories.
-
#anon_mkdir_write_enable=YES
-
#
-
# Activate directory messages – messages given to remote users when they
-
# go into a certain directory.
-
dirmessage_enable=YES
-
#
-
force_dot_files=YES
-
# If enabled, vsftpd will display directory listings with the time
-
# in your local time zone. The default is to display GMT. The
-
# times returned by the MDTM FTP command are also affected by this
-
# option.
-
use_localtime=YES
-
#
-
# Activate logging of uploads/downloads.
-
xferlog_enable=YES
-
#
-
# Make sure PORT transfer connections originate from port 20 (ftp-data).
-
connect_from_port_20=YES
-
#
-
# If you want, you can arrange for uploaded anonymous files to be owned by
-
# a different user. Note! Using “root” for uploaded files is not
-
# recommended!
-
#chown_uploads=YES
-
#chown_username=whoever
-
#
-
# You may override where the log file goes if you like. The default is shown
-
# below.
-
#xferlog_file=/var/log/vsftpd.log
-
#
-
# If you want, you can have your log file in standard ftpd xferlog format.
-
# Note that the default log file location is /var/log/xferlog in this case.
-
#xferlog_std_format=YES
-
#
-
# You may change the default value for timing out an idle session.
-
idle_session_timeout=900
-
#
-
# You may change the default value for timing out a data connection.
-
#data_connection_timeout=120
-
#
-
# It is recommended that you define on your system a unique user which the
-
# ftp server can use as a totally isolated and unprivileged user.
-
#nopriv_user=ftpsecure
-
#
-
# Enable this and the server will recognise asynchronous ABOR requests. Not
-
# recommended for security (the code is non-trivial). Not enabling it,
-
# however, may confuse older FTP clients.
-
#async_abor_enable=YES
-
#
-
# By default the server will pretend to allow ASCII mode but in fact ignore
-
# the request. Turn on the below options to have the server actually do ASCII
-
# mangling on files when in ASCII mode.
-
# Beware that on some FTP servers, ASCII support allows a denial of service
-
# attack (DoS) via the command “SIZE /big/file” in ASCII mode. vsftpd
-
# predicted this attack and has always been safe, reporting the size of the
-
# raw file.
-
# ASCII mangling is a horrible feature of the protocol.
-
#ascii_upload_enable=YES
-
#ascii_download_enable=YES
-
#
-
# You may fully customise the login banner string:
-
ftpd_banner=Your welcome message
-
#
-
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
-
# useful for combatting certain DoS attacks.
-
#deny_email_enable=YES
-
# (default follows)
-
#banned_email_file=/etc/vsftpd.banned_emails
-
#
-
# You may restrict local users to their home directories. See the FAQ for
-
# the possible risks in this before using chroot_local_user or
-
# chroot_list_enable below.
-
#chroot_local_user=YES
-
#
-
# You may specify an explicit list of local users to chroot() to their home
-
# directory. If chroot_local_user is YES, then this list becomes a list of
-
# users to NOT chroot().
-
#chroot_local_user=YES
-
#chroot_list_enable=YES
-
# (default follows)
-
#chroot_list_file=/etc/vsftpd.chroot_list
-
#
-
# You may activate the “-R” option to the builtin ls. This is disabled by
-
# default to avoid remote users being able to cause excessive I/O on large
-
# sites. However, some broken FTP clients such as “ncftp” and “mirror” assume
-
# the presence of the “-R” option, so there is a strong case for enabling it.
-
#ls_recurse_enable=YES
-
#
-
# Debian customization
-
#
-
# Some of vsftpd’s settings don’t fit the Debian filesystem layout by
-
# default. These settings are more Debian-friendly.
-
#
-
# This option should be the name of a directory which is empty. Also, the
-
# directory should not be writable by the ftp user. This directory is used
-
# as a secure chroot() jail at times vsftpd does not require filesystem
-
# access.
-
secure_chroot_dir=/var/run/vsftpd/empty
-
#
-
# This string is the name of the PAM service vsftpd will use.
-
pam_service_name=vsftpd
-
#
-
pasv_min_port=44950
-
pasv_max_port=45000
-
# This option specifies the location of the RSA certificate to use for SSL
-
# encrypted connections.
-
#rsa_cert_file=/etc/ssl/private/vsftpd.pem
- On line 91, type your welcome message.
- On lines 132 and 133 are the minimum and maximum ports passive connections. You´ll need them if you install a firewall later. Change them to any unspecified port range (see what ports are unspecified here).
restart vsftpd
You can now login to your server using FTP (using the user account you created before. Root logins will not work.)
8. Webmin
Webmin is a server control panel similar to cPanel and Plesk, but it is free. First get the download path for the latest .tar.gz version here. Then download and install it on your server:
-
wget http://downloadpath/webmin-x.x.x.tar.gz
-
tar xzf webmin-x.x.x.tar.gz
-
cd /webmin
-
./setup.sh
9.Things to set-up before continuing
Now is a good time to do certain tasks that should be performed.
First, I recommend, as a security precaution, to change the SSH port using Webmin (Servers > SSH server > Networking). Don´t forget to click apply changes after changing the port number, or to update the port number in the PuTTY configuration window.
We also have to add the user you use to make FTP connections to the www-data group, so that there isn´t any permission errors when we install WordPress. First go to System > Users and Groups and select the user account you use to make your FTP connections. Go to the Group membership section and set Primary Group to www-data. Now go to Secondary groups and add the group with the same name as the user account. Also add the sudo group if you want this user account to be able to use the sudo command. Now set Change group ID on files? to All files.
chown -R username /usr/share/nginx/www
Replacing username with the user you´ve just added to the www-data group.
We`re now ready to set up Memcached
10. Memcached
Memcached is a general-purpose distributed memory caching system. It is very easy to install. Just type:
apt-get install memcached php5-memcached
And you´re done! Instructions on how to integrate it into WordPress here.
11. EAccelerator
EAccelerator is a caching extension for PHP that stores PHP scripts in their compiled state in shared memory.
First, we need to download the latest version of EAccelerator:
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
Now let´s compile and install it:
-
tar xvjf eaccelerator-0.9.6.1.tar.bz2
-
cd eaccelerator-0.9.6.1
-
phpize
-
./configure –enable-eaccelerator=shared
-
make
-
make install
nano /etc/php5/cgi/php.ini
And insert this just after (PHP)
-
zend_extension = “/usr/lib/php5/20090626/eaccelerator.so”
-
eaccelerator.shm_size = “32″
-
eaccelerator.cache_dir = “/var/cache/eaccelerator”
-
eaccelerator.enable = “1″
-
eaccelerator.optimizer = “1″
-
eaccelerator.check_mtime = “1″
-
eaccelerator.debug = “0″
-
eaccelerator.filter = “”
-
eaccelerator.shm_max = “0″
-
eaccelerator.shm_ttl = “0″
-
eaccelerator.shm_prune_period = “0″
-
eaccelerator.shm_only = “0″
-
eaccelerator.compress = “1″
-
eaccelerator.compress_level = “9″
-
eaccelerator.allowed_admin_path = “/usr/share/nginx/www/eaccelerator/control.php”
/etc/init.d/php-fastcgi restart
Now we´ll enable the EAccelerator control panel:
-
mkdir /usr/share/nginx/www/eaccelerator
-
mv control.php /usr/share/nginx/www/eaccelerator
-
chmod 644 /usr/share/nginx/www/eaccelerator/control.php
-
nano /usr/share/nginx/www/eaccelerator/control.php
12. And finally… WordPress
We are now ready to install WordPress. First we´ll configure nginx so pretty permalinks work. Open the config file:
nano /etc/nginx/sites-available/default
Now find:
-
location / {
-
# First attempt to serve request as file, then
-
# as directory, then fall back to index.html
-
try_files $uri $uri/ /index.html;
-
if (!-e $request_filename) {
-
rewrite ^(.+)$ /index.php?q=$1 last;
-
}
location /doc {
Add:
-
location /wp-config.php {
-
deny all;
-
}
-
location ~ /.ht {
-
deny all;
-
}
/etc/init.d/nginx restart
Now we´re ready to install WordPress. Make shure you are logged in using the user account you added to the www-data group in step 9 (following this procedure wil install it in the root of your site):
-
cd /usr/share/nginx/www
-
wget http://wordpress.org/latest.tar.gz
-
tar xzf latest.tar.gz
-
cd wordpress
-
mv * ..
-
rm -rf wordpress
-
chmod -R 755 /usr/share/nginx/www
-
chmod -R 775 wp-content
-
chmod 664 wp-config.php
After installing go to SSH and type
chmod 640 /usr/share/nginx/www/wp-config.php
And you´re done! By following this tutorial you have (hopefully) gone from a blank box to a sophisticatedly set-up VPS capable of handling almost anything. I hope that this tutorial is both accurate and easy to understand. If you have any problems please leave a comment below.
It is a inspiring post and it has a significant meaning and thanks for sharing the information.
ReplyDeleteWebmail Login
yo welcome
Delete