您的当前位置:首页正文

Debian/Ubuntu下搭建wordpress教程

来源:要发发知识网

下载并安装LNMP一键安装包

wget -c  && tar zxf lnmp1.2-full.tar.gz && cd lnmp1.2-full && ./install.sh lnmp

如需要安装LNMPA或LAMP,将./install.sh 后面的参数替换为lnmpa或lamp即可。
按上述命令执行后,会出现如下提示:

+------------------------------------------------------------------------+
|          LNMP V1.2 for Ubuntu Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|        A tool to auto-compile & install LNMP/LNMPA/LAMP on Linux       |
+------------------------------------------------------------------------+
|          For more information please visit          |
+------------------------------------------------------------------------+
Please setup root password of MySQL.(Default password: root)
Please enter: 

需要设置MySQL的root密码(不输入直接回车将会设置为root),输入后回车进入下一步,如下图所示:

Do you want to enable or disable the InnoDB Storage Engine?
Default enable,Enter your choice [Y/n]: 

这里需要确认是否启用MySQL InnoDB,如果不确定是否启用可以输入 y ,输入 y 表示启用,输入 n 表示不启用。默认为y 启用,输入后回车进入下一步,选择MySQL版本:

You have 5 options for your DataBase install.
1: Install MySQL 5.1.73
2: Install MySQL 5.5.42 (Default)
3: Install MySQL 5.6.23
4: Install MariaDB 5.5.42
5: Install MariaDB 10.0.17
Enter your choice (1, 2, 3, 4 or 5): 

输入MySQL或MariaDB版本的序号,回车进入下一步,选择PHP版本:

You have 5 options for your PHP install.
1: Install PHP 5.2.17
2: Install PHP 5.3.29
3: Install PHP 5.4.41 (Default)
4: Install PHP 5.5.25
5: Install PHP 5.6.9
Enter your choice (1, 2, 3, 4 or 5): 

输入PHP版本的序号,回车进入下一步,选择是否安装内存优化:

You have 3 options for your Memory Allocator install.
1: Don't install Memory Allocator. (Default)
2: Install Jemalloc
3: Install TCMalloc
Enter your choice (1, 2 or 3): 

可以选择不安装、Jemalloc或TCmalloc,输入对应序号回车。
如果是LNMPA或LAMP的话还需要设置管理员邮箱,再选择Apache版本

提示"Press any key to install...or Press Ctrl+c to cancel"后,按回车键确认开始安装。 LNMP脚本就会自动安装编译Nginx、MySQL、PHP、phpMyAdmin、Zend Optimizer这几个软件。

============================== Check install ==============================
Checking ...
Nginx: OK
MySQL: OK
PHP: OK
PHP-FPM: OK
+------------------------------------------------------------------------+
|          LNMP V1.2 for Ubuntu Linux Server, Written by Licess          |
+------------------------------------------------------------------------+
|         For more information please visit           |
+------------------------------------------------------------------------+
|    lnmp status manage: lnmp {start|stop|reload|restart|kill|status}    |
+------------------------------------------------------------------------+
|  phpMyAdmin: http://IP/phpmyadmin/                                     |
|  phpinfo: http://IP/phpinfo.php                                        |
|  Prober:  http://IP/p.php                                              |
+------------------------------------------------------------------------+
|  Add VirtualHost: lnmp vhost add                                       |
+------------------------------------------------------------------------+
|  Default directory:                               |
+------------------------------------------------------------------------+
|  MySQL/MariaDB root password: root                          |
+------------------------------------------------------------------------+
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              http://lnmp.org              |
+-------------------------------------------+
nginx (pid 31181 31179) is running...
php-fpm is runing!
 * MySQL running (31504)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp6       0      0 :::22                   :::*                    LISTEN     

安装时间可能会几十分钟到几个小时不等,主要是机器的配置网速等原因会造成影响。
如果显示Nginx: OK,MySQL: OK,PHP: OK
并且Nginx、MySQL、PHP都是running,80和3306端口都存在,并Install lnmp V1.2 completed! enjoy it.的话,说明已经安装成功。

添加虚拟主机

执行:lnmp vhost add 出现如下界面:

    root@host:~/lnmp1.2-full# lnmp vhost add
    +-------------------------------------------+
    |    Manager for LNMP, Written by Licess    |
    +-------------------------------------------+
    |              http://lnmp.org              |
    +-------------------------------------------+
    Please enter domain(example:  
     ======================================
     Your domain: 
     ======================================
    Do you want to add more domain name? (y/n) y
    Enter domain name(example: lnmp.org *.lnmp.org): 
    domain list: 
    Please enter the directory for the domain: 
    (Default directory:  
    Virtual Host Directory: 
     ===========================
    Allow Rewrite rule? (y/n)
     ===========================
    y
    Please enter the rewrite of programme: 
    wordpress,discuz,typecho,sablog,dabr rewrite was exist.
    (Default rewrite: other):wordpress
     ===========================
    You choose rewrite=wordpress
     ===========================
     ===========================
    Allow access_log? (y/n)
     ===========================
    n
     ======================================================
    Create database and MySQL user with same name (y/n)
     ======================================================
    y
    verify your current MySQL root password: root
    MySQL root password correct.
    Enter database name: root
    Your will create a database and MySQL user with same name: root
    Please enter password for mysql user root: root
    Your password: root 
     ======================================================
    Create ftp account (y/n)
     ======================================================
    y
    Enter ftp account name: user
    Enter password for ftp account user: user
    Press any key to start create virtul host...

最后的信息大概是这样的

     ================================================
    Virtualhost infomation:
    Your domain: 
    Home Directory: 
    Rewrite: wordpress
    Enable log: no
    Database username: root
    Database userpassword: root
    Database Name: root
    FTP account name: user
    FTP account password: user
     ================================================

安装wordpress

先切换到网站目录下

    cd 
    wget http://cn.wordpress.org/wordpress-3.9-zh_CN.zip
    unzip wordpress-3.9-zh_CN.zip
    cp -R wordpress/* 

设置目录权限

    cd 
    chmod -R 777 wp-admin/
    chmod -R 777 wp-content/
    chmod -R 777 wp-includes/
    chmod -R 777 wp-config-sample.php
    chmod -R 777 readme.html

创建数据库

dns解析

最后将a记录解析到服务器ip,然后在浏览器里面输入刚才设置域名即可开始安装,按照提示输数据库名,账号密码之后即可开始安装。
到此在VPS上用lnmp搭wordpress就完成了。

配置wordpress

数据库名:wordpress
用户名:root
密码:root
数据库主机:localhost
表前缀:wp_android
后面就是配置站点信息了,这个是以后登录wordpress后台需要的.

由于当前wp版本是3.9,不是最新的,系统会提示更新,如果此时点击立即更新是需要输入ftp账号等信息的。
但是之前使用其他服务商的产品没有这个过程,怎么样可以省去这个步骤呢。

chattr -ais  
chown -R  

现在点击下立即更新试试,不用输入ftp账号信息了吧。

参考连接

  • 原文链接:
  • 详细安装
  • LNMP一键安装包 PHP自动升级脚本:
  • 管理lnmp常用命令,lnmp重启,start|stop|reload|restart等命令:
  • LNMP添加、删除虚拟主机及伪静态使用教程:
  • LNMP下FTP服务器的安装与使用方法(Pureftpd和Proftpd)
  • Chown operation not permitted for root: