Deploy PHP environment and WordPress on Ubuntu 14.04

Source: Internet
Author: User
Tags image processing library mcrypt pear install wordpress

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 is a lightweight, flexible configuration that specializes in concurrent WEB servers.


PHP-FPM is the best operating mode currently recommended by the Government.


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 ' ' >> ~/.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:


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://

Unzip the file:

Unzip Wordpress-*.zip

To set file permissions:

Chmod-r. WordPress

To delete an installation package:

RM Wordpress-*.zip

Back to Root:


Configure PHP-FPM

Create a process pool for WordPress:


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.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:


Create a new site:


This profile has rewritten the request to index.php and can use the fixed link feature directly in WordPress:

server {Listen 80;  server_name;  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 ^/(. *) $ permanent;}

Then we need to fix a Bug with Nginx and php-fpm mates:


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:


# You need to enter your MySQL root password

# Create a database


# Create a new user for WordPress

CREATE USER ' wordpress ' @ ' localhost ' identified by ' password ';

# Grant Permissions

GRANT all privileges on ' WordPress '. * to ' WordPress ' @ ' localhost ';

# exit

OK, the configuration is complete, we can restart the server directly, so all services will reboot and use the new configuration:


Deploy PHP environment and WordPress on Ubuntu 14.04

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.