Install WordPress on debian 7 x64(wheezy)

wordpress安装

对于在自己购买的vps上搭建wordpress博客的用户而言,需要先手动搭建wordpress安装环境,然后按照wordpress官网教程安装wordpress。本文将介绍在vultr的vps上搭建wordpress安装环境的步骤。主要参考了vultr documentationwordpress documentation

安装环境:debian 7 x64 (wheezy) / vps : vultr
  1. Install Nginx

    root@localhost:~# apt-get install python-software-properties

    root@localhost:~# add-apt-repository -y ppa:rtcamp/nginx

    root@localhost:~# apt-get update

    root@localhost:~# apt-get install nginx

    root@localhost:~# service nginx start

  2. Test if the server is up and running.

    open in your favorite browser:http://YOUR-VPS-IP

    IT should take you to Nginx's default landing page.

  3. Install PHP 5.5

    root@localhost:~# add-apt-repository ppa:ondrej/php5

    root@localhost:~# apt-get update

    root@localhost:~# apt-get install php5-common php5-mysqlnd php5-xmlrpc php5-curl

    php5-gd php5-cli php5-fpm php-pear php5-dev php5-imap php5-mcrypt

    If you want to check your PHP version, run the following command:

    root@localhost:~# php -v

  4. Edit php5-fpm configuration file

    root@localhost:~# vi /etc/php5/fpm/php.ini

    search for "cgi.fix_pathinfo=", uncomment it (delete ;) and change 1 to 0.

    After changes, the line should look like this:

    cgi.fix_pathinfo=0

    then save and exit.

    root@localhost:~# service php5-fpm restart
  5. Install MySQL

    root@localhost:~# apt-get install mysql-server

    During the installation process, you will be asked to set a root password for MySQL. Once you have set the root password, we will
    have to tell MySQL to generate the directory structure where it will store databases.

    root@localhost:~# mysql_install_db

    root@localhost:~# mysql_secure_installation

    Just type the MySQL root password and type n if you don’t want to change it. After that, type y to every question.

  6. Set Timezone

    By default, the timezone of your server is UTC. If you're living in a different timezone, you can change it by typing in the following command:

    root@localhost:~# dpkg-reconfigure tzdata

  7. Configuring Nginx to serve WordPress

    root@localhost:~# vi /etc/nginx/sites-available/wordpress

    paste the code in the link below in it :

    nginx configuration

    root@localhost:~# ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

    root@localhost:~# vi /etc/nginx/nginx.conf

    Make sure that the number of worker processes is equal to the number of cores in your instance.
    user root;
    
    worker_processes 1;
    
    pid /run/nginx.pid;
    
    Add use epoll; to the events block.
    events {
    
    worker_connections 4096;
    
    multi_accept on;
    
    use epoll;
    
    }
    
    Add client_max_body_size and server_tokens off directive. Set keepalive_timeout to 30 seconds.
    ##
    
    # Basic Settings
    
    ##
    
    sendfile on;
    
    tcp_nopush on;
    
    tcp_nodelay on;
    
    keepalive_timeout 30;
    
    types_hash_max_size 2048;
    
    server_tokens off;
    
    client_max_body_size  100m;
    
    # server_names_hash_bucket_size 64;
    
    # server_name_in_redirect off;
    
    include /etc/nginx/mime.types;
    
    default_type application/octet-stream;
    
    Make sure that the whole Gzip settings block looks like this:
    ##
    
    # Gzip Settings
    
    ##
    
    gzip on;
    
    gzip_disable "msie6"; gzip_vary on;
    
    gzip_proxied any;
    
    gzip_comp_level 6;
    
    gzip_buffers 16 8k;
    
    gzip_http_version 1.1;
    
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
    root@localhost:~# service nginx restart
  8. Configure PHP

    root@localhost:~# vi /etc/php5/fpm/php.ini

    search for "upload_max_filesize" and set it to 100M.

    upload_max_filesize=100M

    do the same with "post_max_size". "post_max_size" needs to be the same size or larger than "upload_max_filesize".

    post_max_size=100M

    Restart PHP

    root@localhost:~# service php5-fpm restart

  9. Setting up the MySQL database

    root@localhost:~# mysql -u root -p

    enter your mysql password for root. this is done in step 5.

    mysql> create database wordpress;  #the database name can be arbitrary

    mysql> grant all privileges on wordpress.* to root@localhost identified by '2398_fdjkj';  

    here identified password is the combination of random chars.

    mysql> flush privileges;

    mysql> exit

  10. Install WordPress Files

    root@localhost:~# cd /

    root@localhost:~# wget http://wordpress.org/latest.tar.gz

    root@localhost:~# tar -zxvf latest.tar.gz

    root@localhost:~# cd wordpress

    root@localhost:~# mv wp-config-sample.php wp-config.php

    root@localhost:~# vi wp-config.php

    search for 'DB_NAME', 'DB_USER', 'DB_PASSWORD' and change them with correct infomation.
    //** MySQL settings - You can get this info from your web host ** //
    
    /** The name of the database for WordPress */
    
    define( 'DB_NAME', 'database_name_here' );
    
    /** MySQL database username */
    
    define( 'DB_USER', 'username_here' );
    
    /** MySQL database password */
    
    define( 'DB_PASSWORD', 'password_here' );
    
    /** MySQL hostname */
    
    define( 'DB_HOST', 'localhost' );
    
  11. Give the permissions of /wordpress  to www-data user.

    php5-fpm默认属于www-data用户组,但是其权限很低,比如不能创建文件夹,所以需要对其授权.

    root@localhost:~# usermod -a -G www-data www-data

  12. Run Install Script

    type the site in your browser:

    http://your-domain/wp-admin/install.php

    then start the configure of your wordpress.

Done!

发表评论

邮箱地址不会被公开。 必填项已用*标注