Software and version selection
Ubuntu 14.04
Ubuntu is one of the most current users of the distribution version, behind the large local 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 supported the best version.
Nginx
Nginx is a lightweight, flexible configuration that specializes in concurrent WEB servers.
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 recommended that we use MySQL.
Basic Configuration
Usually when you create a VPS, you get an IP and a root password, so you first use SSH to mount your server:
SSH [email protected]
# If you have a warning enter Yes to confirm, then enter your root password
Configure the public key login, save every login to enter the password, it is very recommended that the public key as I upload to a public address, so long as a command can be set up:
mkdir ~/.ssh; Curl ' https://raw.githubusercontent.com/jysperm/meta/master/Key/JyAir.pub ' >> ~/.ssh/authorized_keys; Chmod-r ~/.ssh;
Then update the package list to upgrade the existing packages:
Apt-get Updateapt-get Upgrade
To modify the hostname, it is best to change to a domain name that does have access to this server:
Vi/etc/hostnamevi/etc/hosts
Install packages
apt-get install nginx postfix php5-fpm mariadb-server memcachedapt-get Install php-pear php5-mysql php5-curl php5-gd php5-mcrypt php5-memcacheapt-get install python make screen git wget zip unzip iftop vim curl htop iptraf nethogsnginx: Web Server postfix: smtp Server, Used to support sending mail from local php5-fpm: php process manager, and PHP interpreter mariadb-server: class MySQL The database memcached: memory-based caching, and many programs use the php-pear: php Package Manager php5-mysql: php mysql Database driver php5-curl: a HTTP protocol library php5-gd: an image processing library php5-mcrypt: an encryption 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 popular version control tool wget, curl: commonly used file download tool zip, unzip: zip compression and decompression tool Iftop, iptraf, nethogs: Common flow monitoring Tool vim: a common editor htop: a commonProcess monitoring Tools
Install WordPress
Create a new normal user and switch to that user
AddUser Wordpresssu WORDPRESSCD ~
Download WordPress, please go to the official website to view the latest version of:
wget Http://cn.wordpress.org/wordpress-3.9-zh_CN.zip
Unzip the file:
Unzip Wordpress-*.zip
To set file permissions:
Chmod-r. WordPress
To delete an installation package:
RM Wordpress-*.zip
Back to Root:
Exit
Configure PHP-FPM
Create a process pool for WordPress:
Vi/etc/php5/fpm/pool.d/wordpress.conf
This is a typical configuration file, by listening to the Unix Socket to provide services, dynamically adjust the number of processes, up to 10 processes, a minimum of 3 processes:
[Wordpress]user = Wordpressgroup = Wordpresslisten =/home/wordpress/phpfpm.socklisten.owner = Wordpresslisten.group = Wordpresslisten.mode = 0660pm = Dynamicpm.max_children = 10pm.min_spare_servers = 3pm.max_spare_servers = 5slowlog =/Home /wordpress/phpfpm.slowlogrequest_slowlog_timeout = 5srequest_terminate_timeout = 15sphp_admin_value[error_log] =/ Home/wordpress/phpfpm_error.logphp_admin_flag[log_errors] = On
Configure Nginx
Delete Nginx's default site:
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 80; 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 domains to your site, you can add this one:
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 mates:
Vi/etc/nginx/fastcgi_params
Change the line starting with Fastcgi_param Script_filename to:
Fastcgi_param script_filename $document _root$fastcgi_script_name;
To add permissions to read the WordPress file for Nginx:
Usermod-g wordpress-a Www-data
Configure MySQL
Go to the MySQL console:
Mysql-p
# You 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 ';
# Grant Permissions
GRANT all privileges on ' WordPress '. * to ' WordPress ' @ ' localhost ';
# exit
QUIT
Restart
OK, the configuration is complete, we can restart the server directly, so all services will reboot and use the new configuration:
Reboot
Deploy PHP environment and WordPress on Ubuntu 14.04