想在本地搭建WordPress博客站点作测试用?本教程一步一步教您在linux上搭建一个LAMP(Linux, Apache, MySQL, php)服务器并部署WordPress博客。
请注意在复制粘贴命令时注意按自己的环境进行修改。
本文因包含大量图片,请不要在数据网络下阅读本文。转载本文章时请注明原作者@101对双生儿。
第一步:安装Apache
打开“终端”(Ctrl+Alt+T),输入 sudo apt-get install apache2
![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/5awuqrmg2i330.gif)
安装完成后输入 sudo /etc/init.d/apache2 restart重启Apache![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/risgmj1udun30.gif)
打开浏览器,访问http://localhost,若看到"Itworks!"如下图所示则安装成功
此时本地站点目录默认为/var/www
第二步,安装PHP
终端中输入 sudo apt-get install libapache2-mod-php5php5![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/xmtd34dfv3j30.gif)
接着可以安装一些PHP扩展模块
终端中输入 sudo apt-get install php5-common php5-dev php5-cgiphp5-fpm php-apc php5-mysql php5-curl php5-gd php5-idn php-pearphp5-mcrypt php5-memcache php5-ming php5-recode php5-tidyphp5-xmlrpc php5-xsl php5-imagick php5-imap php5-recode php5-snmpphp5-sqlite php5-xmlrpc![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/oi2kn4dqaqv30.gif)
安装完成后输入 sudo /etc/init.d/apache2 restart重启Apache让其加载PHP扩展模块![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/0keuephinzz30.gif)
接下来创建一个测试页面来显示PHP是否能正常运行
终端中输入 sudo gedit /var/www/test.php打开Gedit编辑器![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/ubc4k3szkli31.gif)
输入以下代码:
![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/bkzwkdakokv31.gif)
然后打开浏览器,访问http://localhost/test.php。若出现以下说明PHP能够正常运行,且页面中显示了当前已安装的扩展模块。![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/kstpa2ej4aq31.gif)
第三步,安装MySQL
终端中输入 sudo apt-get install mysql-servermysql-client![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/jwp5uws1igm31.gif)
安装的最后会要求里输入管理员帐号root的密码。注意这里的root密码不是Linux的root密码,而是给MySQL设定的root密码。![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/twdxstiwmt131.gif)
![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/jgesehnni1g31.gif)
第四步,安装phpMyAdmin
终端中输入 sudo apt-get install phpmyadmin![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/rz1bfh2ofuu31.gif)
安装过程中会要求选择Web server,使用空格键选定apache2,按Tab键然后确定![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/x04lblrrxxq31.gif)
选择“是”为phpMyAdmin设置数据库![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/qpqpklhomqa31.gif)
输入之前设置的MySQL数据库连接密码以及phpMyAdmin密码![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/ewyvwt1gxhb31.gif)
然后将phpMyAdmin与Apache建立连接,终端中输入 sudo ln -s/usr/share/phpmyadmin /var/www![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/temvfz303yo31.gif)
接着打开浏览器,访问http://localhost/phpmyadmin,使用之前设置的root帐户和密码登录![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/ppow2bqqtlt31.gif)
若出现以下控制页面说明phpMyAdmin安装成功
至此LAMP服务器搭建完成
第五步,安装WordPress
访问http://cn.wordpress.org下载WordPress压缩包
本例中,终端中输入 wgethttp://cn.wordpress.org/wordpress-3.8-zh_CN.tar.gz下载最新版3.8至当前目录/home/CSSaug![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/wwzid14ncaw31.gif)
解压缩文件
本例中,终端中输入
cd /var/www
sudo tar zxvf/home/cssaug/wordpress-3.8-zh_CN.tar.gz
mv wordpress cssaug
将WordPress压缩包解压缩到/var/www,再将站点根目录名由wordpress重命名为cssaug![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/2l33rtyeqo431.gif)
![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/whmmvekk2nz31.gif)
然后打开浏览器,访问http://localhost/cssaug/wp-admin/install.php安装WordPress站点![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/j35pbs0rujj31.gif)
![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/120vh3nhsal31.gif)
接着需要为WordPress站点配置一个数据库。
本例中,登录phpMyAdmin,为WordPress站点新建一个名为cssaug的数据库![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/zulckq3wipg31.gif)
填写数据库连接信息![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/zjrg5eo34bn31.gif)
设置WordPress站点信息![[网站]Ubuntu下搭建本地WordPress站点 [网站]Ubuntu下搭建本地WordPress站点](http://s1.VeVb.com/20150728/0otccgqxjkp31.gif)
最后为本地站点设置权限以便将来进行更新
本例中,终端中输入
sudo chmod -R 777 /var/www/cssaug
sudo chown -R www-data/var/www/cssaug
至此,WordPress本地站点安装完成。
参考:
1. http://www.VEVb.com/lynch_world/archive/2012/01/06/2314717.html2. http://www.wincold.com/archives/145.html3. http://imcn.me/html/y2012/12401.html4. http://developer.51cto.com/art/201110/299303.htm5. http://farlee.info/archives/linux-ubuntu-lamp-apache-mysql-php-phpmyadmin-install-configuration.html
原文:http://blog.sina.com.cn/s/blog_6e3638010101gss5.html
新闻热点
疑难解答