发表于: 2016-4-25 13:17:16 | 显示全部楼层

Wordpress-on-iMX6.jpg


安装常用的工具和库

安装Linux下常用的工具和库,例如python2.7、libxml2、apt-src等。

  1. sudo apt-get update
  2. sudo apt-get install python2.7-dev
  3. sudo apt-get install libxml2-dev
  4. sudo apt-get install apt-src \
  5. scons \
  6. mingw32-runtime \
  7. p7zip-full \
  8. gawk \
  9. gzip \
  10. perl \
  11. autoconf \
  12. m4 \
  13. automake \
  14. libtool \
  15. libncurses5-dev \
  16. gettext \
  17. gperf \
  18. dejagnu \
  19. expect \
  20. tcl \
  21. autogen \
  22. flex \
  23. flip \
  24. bison \
  25. tofrodos \
  26. texinfo \
  27. g++ \
  28. gcc-multilib \
  29. libgmp3-dev \
  30. libmpfr-dev \
  31. debhelper \
  32. texlive \
  33. texlive-extra-utils
复制代码

安装Apache

我尝试使用指令“sudo apt-get install apache2”,但是它没有正确安装Apache(我无法运行“sudo service apache2 restart”)。所以我重新编译源码后再进行安装。

下载源代码:

  1. cd
  2. mkdir tmp
  3. cd tmp
  4. wget http://tux.rainside.sk/apache//httpd/httpd-2.2.31.tar.bz2
  5. tar -xvf httpd-2.2.31.tar.bz2
  6. cd httpd-2.2.31
复制代码

编译并安装Apache:

  1. ./configure --prefix=/usr/local/apache2
  2. make
  3. make install
复制代码

设置“ServerName”。打开“/usr/local/apache2/conf/httpd.conf”文件。

  1. nano /usr/local/apache2/conf/httpd.conf
复制代码

查找“ServerName”,放置以下代码:

  1. ServerName localhost:80
复制代码

重新启动后Apache自动启动。

创建“/etc/init.d/apache2”:

  1. sudo nano /etc/init.d/apache2
复制代码

将以下内容添加到该文件:

  1. #!/bin/sh
  2. case "$1" in
  3. start)
  4. echo "Starting Apache ..."
  5. # Change the location to your specific location
  6. /usr/local/apache2/bin/apachectl start
  7. ;;
  8. stop)
  9. echo "Stopping Apache ..."
  10. # Change the location to your specific location
  11. /usr/local/apache2/bin/apachectl stop
  12. ;;
  13. graceful)
  14. echo "Restarting Apache gracefully..."
  15. # Change the location to your specific location
  16. /usr/local/apache2/bin/apachectl graceful
  17. ;;
  18. restart)
  19. echo "Restarting Apache ..."
  20. # Change the location to your specific location
  21. /usr/local/apache2/bin/apachectl restart
  22. ;;
  23. *)
  24. echo "Usage: '$0' {start|stop|restart|graceful}"
  25. exit 64
  26. ;;
  27. esac
  28. exit 0
复制代码

编辑权限:

  1. sudo chmod u+x /etc/init.d/apache2
复制代码

重新启动后使用以下指令启用自动启动:

  1. sudo update–rc.d apache2 defaults #possibly try without sudo
复制代码

启动服务器:

  1. sudo service apache2 start
复制代码

注意:可能会用到一下指令:

  1. /usr/local/apache2/bin/apachectl start #original path
  2. sudo service apache2 stop
  3. sudo service apache2 start
  4. sudo service apache2 restart
复制代码

测试WEB服务器是否工作

检查OpenRex的IP地址,运行:

  1. root@ubuntu-imx6:/usr/local/apache2/htdocs# ifconfig
  2. eth0      Link encap:Ethernet  HWaddr 00:0d:15:00:dc:ed
  3.           inet addr:192.168.0.39  Bcast:192.168.0.255  Mask:255.255.255.0
  4.           inet6 addr: fe80::20d:15ff:fe00:dced/64 Scope:Link
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  6.           RX packets:11705 errors:0 dropped:0 overruns:0 frame:0
  7.           TX packets:10807 errors:0 dropped:0 overruns:0 carrier:0
  8.           collisions:0 txqueuelen:1000
  9.           RX bytes:12306971 (12.3 MB)  TX bytes:1443867 (1.4 MB)

  10. lo        Link encap:Local Loopback
  11.           inet addr:127.0.0.1  Mask:255.0.0.0
  12.           inet6 addr: ::1/128 Scope:Host
  13.           UP LOOPBACK RUNNING  MTU:65536  Metric:1
  14.           RX packets:12 errors:0 dropped:0 overruns:0 frame:0
  15.           TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
  16.           collisions:0 txqueuelen:0
  17.           RX bytes:656 (656.0 B)  TX bytes:656 (656.0 B)

  18. root@ubuntu-imx6:/usr/local/apache2/htdocs#
复制代码

可以看到,OpenRex的IP地址是192.168.0.39。转到PC或者Linux主机,打开互联网浏览器,输入网址:“http://192.168.0.39”,你应该看到一个页面:

  1. It works!
复制代码

很不错,它工作了。所有的apache文件位于“/usr/local/apache2/”,这意味着,该网站的页面都位于“/usr/local/apache2/htdocs/”里面。如果你喜欢的话,可以试着改变当前页面。运行“nano”来编辑“index.html”文件:

  1. nano /usr/local/apache2/htdocs/index.html
复制代码

你可以像这样进行编辑:

  1. <html><body><h1>It works! Perfect!</h1></body></html>
复制代码

刷新OpenRex网站,你应该会看到:

  1. It works! Perfect!
复制代码


安装MySQL

运行以下指令来安装MySQL:

  1. sudo apt-get install mysql-server
复制代码

安装过程中设置admin的密码。测试MySQL是否正在运行:

  1. root@ubuntu-imx6:~/tmp/php-5.6.19# sudo netstat -tap | grep mysql
  2. tcp        0      0 127.0.0.1:mysql         *:*                     LISTEN      21100/mysqld
  3. root@ubuntu-imx6:~/tmp/php-5.6.19#
复制代码

注意:如果服务器没有正常运行,您可以键入以下命令来启动它:

  1. sudo service mysql restart
复制代码

注意:如果你想改变MySQL的默认配置,该文件位于:

  1. nano /etc/mysql/my.cnf
复制代码

安装PHP

下载源代码:

  1. cd ~/tmp
  2. wget http://php.net/get/php-5.6.19.tar.bz2/from/this/mirror
  3. mv mirror php-5.6.19.tar.bz2
  4. tar -xvf php-5.6.19.tar.bz2
  5. cd php-5.6.19
复制代码

配置、编译以及运行PHP测试:

  1. ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
  2. make
  3. make test
复制代码

安装PHP:

  1. make install
  2. cp php.ini-development /usr/local/lib/php.ini
复制代码

如果需要更改的PHP配置,php.ini文件位于:/usr/local/lib/php.ini。


更新Web服务器配置

打开Web服务器的配置文件:

  1. nano /usr/local/apache2/conf/httpd.conf
复制代码

搜索“php5_module”,并确保已启用。你应该看到类似这样的:

  1. LoadModule php5_module modules/libphp5.so
复制代码

搜索“FilesMatch”,并添加以下内容,使其可以处理“PHP”文件:

  1. <FilesMatch \.php[        DISCUZ_CODE_868        ]gt;
  2.     SetHandler application/x-httpd-php
  3. </FilesMatch>
复制代码

搜索"DirectoryIndex",并告诉WordPress自动处理index.php:

  1. DirectoryIndex index.php index.phtml index.html index.htm
复制代码

重新启动Web服务器

  1. sudo service apache2 restart
复制代码


测试PHP

创建 phpinfo.php文件:

  1. nano /usr/local/apache2/htdocs/phpinfo.php
复制代码

里面放入以下内容:

  1. <?php
  2.    phpinfo();
  3. ?>
复制代码

转到你的OpenRex网站,并使用以下链接:“http://192.168.0.39/phpinfo.php”(不要忘记使用你的OpenRex的IP地址)。你应该会看到PHP信息的页面。


安装WordPress

在开始安装WordPress之前,我们将创建MySQL的WordPress用户:

  1. mysql -u root -p
  2. #enter the root password which you used during MySQL installation. I used 'fedevel'
复制代码

创建OpenRex WordPress的数据库:

  1. create database wordpress;
复制代码

创建OpenRex WordPress的用户:

  1. create user 'wordpress'@'localhost' identified by 'fedevel';
复制代码

授予WordPress用户使用WordPress数据库的权限:

  1. grant all on wordpress.* to 'wordpress'@'localhost' identified by 'fedevel';
  2. quit;
复制代码

现在下载WordPress文件:

  1. cd ~/tmp
  2. wget https://wordpress.org/latest.tar.gz
  3. tar -zxvf latest.tar.gz
复制代码

备份当前的Web目录:

  1. mkdir ~/tmp/webbackup
  2. mv /usr/local/apache2/htdocs/* ~/tmp/webbackup/
复制代码

复制WordPress文件到Web服务器目录:

  1. cp -prv ~/tmp/wordpress/* /usr/local/apache2/htdocs/
复制代码

WordPress的Web安装

转到OpenRex网站(打开互联网浏览器,并输入OpenRex的IP地址)。本例中该网址是:http://192.168.0.39/,你会看到类似这样的:“欢迎使用WordPress。在开始之前,我们需要数据库的一些信息,在继续之前您需要了解以下事项.. “。

第1步:设置MySQL

  1. Database Name: wordpress
  2. User Name: wordpress //use the user which you created in the steps above
  3. Password: fedevel //use the password which you assigned to the user
  4. Database Host: localhost
  5. Table Prefix: wp_
复制代码

第2步:wp-config.php文件

在该步骤中,您将看到一条信息,类似于:“对不起,我不能写入wp-config.php文件,您可以手动创建 wp-config.php并将下面的文本粘贴到里面”。创建“/usr/local/apache2/htdocs/wp-config.php”:

  1. nano /usr/local/apache2/htdocs/wp-config.php
复制代码

并且从安装过程中的文本框里复制这些内容,它可能是这样的:

  1. <?php
  2. /**
  3. * The base configuration for WordPress
  4. *
  5. * The wp-config.php creation script uses this file during the
  6. * installation. You don't have to use the web site, you can
  7. * copy this file to "wp-config.php" and fill in the values.
  8. *
  9. * This file contains the following configurations:
  10. *
  11. * * MySQL settings
  12. * * Secret keys
  13. * * Database table prefix
  14. * * ABSPATH
  15. *
  16. * @link https://codex.wordpress.org/Editing_wp-config.php
  17. *
  18. * @package WordPress
  19. */

  20. // ** MySQL settings - You can get this info from your web host ** //
  21. /** The name of the database for WordPress */
  22. define('DB_NAME', 'wordpress');

  23. /** MySQL database username */
  24. define('DB_USER', 'wordpress');

  25. /** MySQL database password */
  26. define('DB_PASSWORD', 'fedevel');

  27. /** MySQL hostname */
  28. define('DB_HOST', 'localhost');

  29. /** Database Charset to use in creating database tables. */
  30. define('DB_CHARSET', 'utf8mb4');

  31. /** The Database Collate type. Don't change this if in doubt. */
  32. define('DB_COLLATE', '');

  33. /**#@+
  34. * Authentication Unique Keys and Salts.
  35. *
  36. * Change these to different unique phrases!
  37. * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
  38. * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
  39. *
  40. * @since 2.6.0
  41. */
  42. define('AUTH_KEY',         'F5k,gn[K14j,|wi:+{13;.1C;shnAz}|7y9^kgbj(6NHXN08@y6`vRug3H~,))ct');
  43. define('SECURE_AUTH_KEY',  '<uYD@tZ=Ux18SZS3+0f@20O,wSegsz|<j|U>b%K|80b^Sz7)u[@5{HmWUqt/oc!t');
  44. define('LOGGED_IN_KEY',    '0$b3sov2BQPPO6$S,=4zROwyttUy&dG(PMVEStXP04U]{9IwOxHE+}8KzlSYVop[');
  45. define('NONCE_KEY',        'H4|Z+Vqg-F+ogK60gGU2!N]CLa`|<1MVusE5g:lgI:^)`uUfG3ho#?KUqoh92RLx');
  46. define('AUTH_SALT',        'OCMVZ6(P/R3QSko?Z3vU&0+Eq@irqzYLRXSdH_:C6rl2l37J[=>v.NOK+Q&G9=*O');
  47. define('SECURE_AUTH_SALT', 'Z`n[NU4z5MBRpC=b-)bm2ai8Y$3T-~N[ZKIab8pDfBG@Bg-Y xo`QKrs6Q]Vb;eh');
  48. define('LOGGED_IN_SALT',   'n?+!( 0m,TaT5,]K/ zjfE|_Le%UZL-(NY(%3}s+aSFR*BOmJ[N@ jBm~TyUJc#U');
  49. define('NONCE_SALT',       ' L%.#p$V)^0eSO b(Hl nYxRY$owA@xchkji(hetfIUv-iUDT=v`m%Fmf;ve?zoX');

  50. /**#@-*/

  51. /**
  52. * WordPress Database Table prefix.
  53. *
  54. * You can have multiple installations in one database if you give each
  55. * a unique prefix. Only numbers, letters, and underscores please!
  56. */
  57. $table_prefix  = 'wp_';

  58. /**
  59. * For developers: WordPress debugging mode.
  60. *
  61. * Change this to true to enable the display of notices during development.
  62. * It is strongly recommended that plugin and theme developers use WP_DEBUG
  63. * in their development environments.
  64. *
  65. * For information on other constants that can be used for debugging,
  66. * visit the Codex.
  67. *
  68. * @link https://codex.wordpress.org/Debugging_in_WordPress
  69. */
  70. define('WP_DEBUG', false);

  71. /* That's all, stop editing! Happy blogging. */

  72. /** Absolute path to the WordPress directory. */
  73. if ( !defined('ABSPATH') )
  74.     define('ABSPATH', dirname(__FILE__) . '/');

  75. /** Sets up WordPress vars and included files. */
  76. require_once(ABSPATH . 'wp-settings.php');
复制代码

第3步:运行安装

点击按钮“Run the install”。


第4步:设置基本的页面信息

  1. Site Title: RexFace //or what you like
  2. Username: fedevel //or what you like
  3. Password: fedevel //or what you like
  4. Your Email: username@example.com //put here your email, your OpenRex wordpress will send you important info e.g. password reset
  5. Search Engine Visibility: Check this, you may not want google to search through your OpenRex web (or if you want, you can uncheck it :)
复制代码

第5步:点击“安装WordPress”

只需按下按钮“Install WordPress”。


第6步:登录

点击“登录”按钮,登录到在OpenRex运行的RexFace网站。


重要提示:如果您的主板的IP地址发生改变,需要编辑“的functions.php”。在我们的示例中:

  1. nano /usr/local/apache2/htdocs/wp-content/themes/twentysixteen/functions.php
复制代码

在“PHP?”后添加以下行:

  1. update_option( 'siteurl', 'http://'.$_SERVER['SERVER_ADDR']);
  2. update_option( 'home', 'http://'.$_SERVER['SERVER_ADDR']);
复制代码

它看起来就像这样:

  1. <?php
  2. update_option( 'siteurl', 'http://'.$_SERVER['SERVER_ADDR']);
  3. update_option( 'home', 'http://'.$_SERVER['SERVER_ADDR']);
  4. /**
  5. * Twenty Sixteen functions and definitions
复制代码

这是必需的,因为当你将服务器移动到不同的IP地址,所有的内部网站链接仍然指向旧的IP地址。





跳转到指定楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题 16 | 回复: 24



手机版|

GMT+8, 2024-4-19 14:08 , Processed in 0.137210 second(s), 6 queries , Gzip On, MemCache On. Powered by Discuz! X3.5

YiBoard一板网 © 2015-2022 地址:河北省石家庄市长安区高营大街 ( 冀ICP备18020117号 )

快速回复 返回顶部 返回列表