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

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 root@106.186.21.33

# 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 the local php5-fpm:php process manager, and PHP interpreter Mariadb-server: Class MySQL database memcached: Memory-based caching, many programs will use 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: An encryption algorithm library php5-memcache:memcached Drive 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: Common file Download tool ZIP, Unzip:zip compression and decompression tool Iftop, Iptraf, nethogs: Common Flow monitoring tools vim: A common editor Htop: a common process monitoring tool

Install WordPress

Create a new normal user and switch to that user

AddUser Wordpresssu WORDPRESSCD ~

Download WordPress, please go to the official website to see the latest version of the download address:

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;  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

  • Related Article

    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: info-contact@alibabacloud.com 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.