Software and version selection
Ubuntu 14.04
Ubuntu is the largest number of users in the distribution, behind a large tyrants maintenance, can be said to be the best choice for lightweight users. And 14.04 is currently the latest LTS version, has been released for six months, the basic is currently supporting the best version.
Nginx
Nginx is a lightweight, flexible, concurrency-capable Web server.
php-fpm
PHP-FPM is the best operating mode currently recommended by the Government.
Mariadb
MySQL's replacement, after all, the current MySQL founder has not advised us to use MySQL anymore.
Basic Configuration
Usually when you create a VPS, you will get an IP and a root password, so first use SSH to board your server:
# If you have a warning input yes to confirm, and then enter your root password
Configure the public key login, save every login to enter the password, very recommended like me to upload the public key to a public address, so long as a command can be set:
mkdir ~/.ssh; Curl ' https://raw.githubusercontent.com/jysperm/meta/master/Key/JyAir.pub ' >> ~/.ssh/authorized_keys; Chmod-r ~/.ssh;
Then update the package list and upgrade the existing packages:
Apt-get Update
Apt-get upgrade
Modify the hostname, preferably to a domain name that does have access to this server:
Vi/etc/hostname
vi/etc/hosts
Installing packages
Apt-get install nginx postfix php5-fpm mariadb-server memcached apt-get install php-pear php5-mysql php5-curl php5-gd
Php5-mcrypt php5-memcache
apt-get install python make screen git wget zip unzip iftop vim Curl Htop Iptraf nethogs
nginx:web server
POSTFIX:SMTP server, used to support sending mail from local
php5-fpm:php process Manager, and PHP interpreter
Mariadb-server: class MySQL Database
Memcached: Memory based caching, many programs use the
php-pear:php Package Manager
php5-mysql:php mysql database driver
php5-curl: An HTTP protocol library
PHP5-GD: An image processing library
Php5-mcrypt: A cryptographic algorithm library
php5-memcache:memcached driver
python: a common scripting language interpreter make
: A common build tool screen
: a common Shell session management tool
git: A common version control tool
wget, curl: Common file Download tool
Zip, unzip:zip compression and decompression tool
iftop, Iptraf, Nethogs: A commonly used flow monitoring tool
vim: A commonly used editor
Htop: A common process monitoring tool
Install WordPress
Create a new normal user and switch to that user
AddUser WordPress
su wordpress
cd ~
Download WordPress, please go to the official website to view the latest version of the download address:
wget Http://cn.wordpress.org/wordpress-3.9-zh_CN.zip
Extract files:
To set file permissions:
To remove the installation package:
Back to Root:
Configure PHP-FPM
Create a process pool for WordPress:
Vi/etc/php5/fpm/pool.d/wordpress.conf
This is a typical configuration file that provides services by listening on Unix sockets, dynamically adjusting the number of processes, up to 10 processes, and the lowest 3 processes:
[WordPress]
user = wordpress
group = wordpress
Listen =/home/wordpress/phpfpm.sock
Listen.owner = WordPress
Listen.group = wordpress
listen.mode = 0660
pm = dynamic
Pm.max_children = pm.min_spare_servers
= 3< C10/>pm.max_spare_servers = 5
slowlog =/home/wordpress/phpfpm.slowlog
request_slowlog_timeout = 5s
Request_terminate_timeout = 15s
Php_admin_value[error_log] =/home/wordpress/phpfpm_error.log
php_admin_ Flag[log_errors] = On
Configure Nginx
Delete the default site for Nginx:
Rm/etc/nginx/sites-enabled/default
Create a new site:
Vi/etc/nginx/sites-enabled/wordpress
This profile has rewritten the request to index.php and can use the "fixed link" feature directly in WordPress:
server {
listen;
server_name jysperm.me;
root/home/wordpress/wordpress;
Index index.html index.php;
AutoIndex off;
Location/{
try_files $uri $uri//index.php;
}
Location ~ \.php$ {
Fastcgi_pass unix:///home/wordpress/phpfpm.sock;
Include Fastcgi_params;
Fastcgi_index index.php
}
}
If you want to jump all other domain names to your site, you can add this paragraph:
server {
listen default_server;
Listen [::]:80 default_server ipv6only=on;
Rewrite ^/(. *) $ http://jysperm.me permanent;
}
Then we need to fix a Bug with Nginx and PHP-FPM:
Vi/etc/nginx/fastcgi_params
Change the line at the beginning of Fastcgi_param Script_filename to:
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Add permissions to read WordPress files for Nginx:
Usermod-g wordpress-a Www-data
Configure MySQL
Access to the MySQL console:
# need to enter your MySQL root password
# Create a database
CREATE DATABASE ' WordPress ';
# Create a new user for WordPress
CREATE USER ' wordpress ' @ ' localhost ' identified by ' password ';
# granting permissions
GRANT all privileges on ' WordPress '. * to ' WordPress ' @ ' localhost ';
# exit
QUIT
Reboot
OK, now that we've configured it, we'll just reboot the server so that all the services will reboot and use the new configuration:
Reboot