Ubuntu14.04VPS: deploy the PHP environment and WordPress

Source: Internet
Author: User
Tags mcrypt php mysql vps install wordpress
Ubuntu14.04Ubuntu is one of the most popular software and version releases. It is well maintained by many local experts and can be said to be the best choice for lightweight users. 14.04 is the latest LTS version and has been released for six months. It is basically the best version currently supported. NginxNginx is a lightweight, flexible configuration, good

The software and version of Ubuntu 14.04 Ubuntu is one of the most popular releases. It is well maintained by many local experts and is the best choice for lightweight users. 14.04 is the latest LTS version and has been released for six months. It is basically the best version currently supported. Nginx is a lightweight, flexible configuration, good

Software and version Selection
  • Ubuntu 14.04

    Ubuntu is one of the most popular versions of Ubuntu. It is well maintained and can be said to be the best choice for lightweight users. 14.04 is the latest LTS version and has been released for six months. It is basically the best version currently supported.

  • Nginx

    Nginx is a lightweight, flexible configuration, and good at concurrent Web servers.

  • PHP-FPM

    PHP-FPM is currently the best run mode officially recommended.

  • MariaDB

    After all, the founder of MySQL does not recommend that we use MySQL.

Basic Configuration

Generally, when you create a VPS, you will get an IP address and a root password. Therefore, first use ssh to log on to your server:

Ssh root@106.186.21.33 # if there is a warning enter yes to confirm, then enter your root Password

Configure the public key to log on, saving the need to enter a password every time you log on. We recommend that you upload the public key to a public address just like me, so that you can set it with one command:

mkdir ~/.ssh; curl 'https://raw.githubusercontent.com/jysperm/meta/master/Key/JyAir.pub' >> ~/.ssh/authorized_keys; chmod -R 700 ~/.ssh;

Update the software package list to upgrade the existing software package:

apt-get updateapt-get upgrade

Change the host name to a domain name that can access this server:

vi /etc/hostnamevi /etc/hosts
Install software package
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 nethogs
  • Nginx: Web Server
  • Postfix: SMTP server, used to support sending mails locally
  • Php5-fpm: PHP Process Manager and PHP interpreter
  • Mariadb-server: MySQL-type Database
  • Memcached: memory-based Cache, which is used by many programs
  • Php-pear: PHP Package Manager
  • Php5-mysql: PHP MySQL database driver
  • Php5-curl: an HTTP protocol Library
  • Php5-gd: An Image Processing Database
  • Php5-mcrypt: a library of encryption algorithms
  • Php5-memcache: Memcached driver
  • Python: a commonly used language interpreter
  • Make: A common build tool
  • Screen: a common Shell session management tool
  • Git: A common version control tool
  • Wget and curl: Common File Download tools
  • Zip, unzip: ZIP compression and decompression tools
  • Iftop, iptraf, and nethogs: common traffic monitoring tools
  • Vim: a common Editor
  • Htop: a common process monitoring tool
Install WordPress

Create a common user and switch

adduser wordpresssu wordpresscd ~

To download WordPress, go to the official website to view the latest version:

wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip

Decompress the file:

unzip wordpress-*.zip

Set file permissions:

chmod -R 750 wordpress

Delete the installation package:

rm wordpress-*.zip

Return 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 that provides services by listening to Unix sockets and dynamically adjusts the number of processes. The maximum number of processes is 10, and the minimum number of processes is 3:

[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 the default Nginx site:

rm /etc/nginx/sites-enabled/default

Create a site:

vi /etc/nginx/sites-enabled/wordpress

This configuration file has rewritten the request to index. php. You can directly use the "Fixed Link" function 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 redirect all other domain names to your site, you can add the following section:

server {    listen 80 default_server;    listen [::]:80 default_server ipv6only=on;    rewrite ^/(.*)$ http://jysperm.me permanent;}

Then we need to fix a Bug that works with Nginx and PHP-FPM:

vi /etc/nginx/fastcgi_params

Setfastcgi_param SCRIPT_FILENAMEThe starting line is changed:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Add the following permissions to read WordPress files for Nginx:

usermod -G wordpress -a www-data
Configure MySQL

Log on to the MySQL console:

Mysql-p # Enter your MySQL root password # create database 'wordpress'; # create user 'wordpress' for wordpress @ 'localhost' identified by 'Password '; # grant all privileges on 'wordpress '. * TO 'wordpress '@ 'localhost'; # exit QUIT.
Restart

Now that the configuration is complete, restart the server directly, so that all services will be restarted and the new configuration will be used:

reboot

Original article address: deploy the PHP environment and WordPress in Ubuntu 14.04 VPS. Thank you for sharing with me.

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.