1.推荐网址
在Ubuntu14.04上安装WordPress4搭建技术博客 - 狮子座流星 - 博客园
https://jingyan.baidu.com/article/3c343ff701b7fc0d377963d0.html
2.搭建LAMP环境
sudo apt-get install lamp-server^
ubuntu 16.04系统下解决MySQL 5.7版本的root用户重置密码问题
ubuntu 16.04系统下解决MySQL 5.7版本的root用户重置密码问题
3.初始化数据库
-
$ sudo mysql -u root -p
-
Enter Password: ...
-
mysql> CREATE DATABASE wordpressdb;
-
mysql> GRANT ALL ON wordpressdb.* TO wordpressuser@localhost IDENTIFIED BY 'wordpresspassword';
-
mysql> GRANT ALL ON wordpressdb.* TO wordpressuser@% IDENTIFIED BY 'wordpresspassword'; (%所有都可以访问)
-
mysql> FLUSH PRIVILEGES;
-
mysql> exit
4.重启apache
sudo /etc/init.d/apache2 restart
5.重启mysql
sudo /etc/init.d/mysql restart
6.下载并配置WordPress
7.参考网址:在Ubuntu14.04上安装WordPress4搭建技术博客 - 狮子座流星 - 博客园
step1
-
$ mkdir temp
-
$ cd temp
-
$ tar zxf wordpress-4.x.tar.gz -C /var/www/html/
-
$ mkdir -p /var/www/html/wordpress/wp-content/uploads
step2:关键更改目录权限为www-data www-data
-
$ sudo chown -R www-data.www-data /var/www/html/wordpress
-
$ sudo chmod -R 755 /var/www/html/wordpress
-
$ sudo chown -R :www-data /var/www/html/wordpress/wp-content/uploads
step3:配置wp-config.php
-
$ cd /var/www/html/wordpress/
-
$ cp wp-config-sample.php wp-config.php
-
$ emacs wp-config.php
-
#wp-config.php
-
...
-
// ** MySQL settings - You can get this info from your web host ** //
-
/** The name of the database for WordPress */ define('DB_NAME', 'wordpressdb');
-
/** MySQL database username */ define('DB_USER', 'wordpressuser');
-
/** MySQL database password */ define('DB_PASSWORD', 'wordpresspassword');
8.配置Apache服务器
-
在/etc/apache2/sites-available/目录下复制一份001-default.conf命名为wordpress.conf,重启apache服务。
-
$ sudo a2ensite wordpress
-
$ sudo service apache2 restart
9.创建.htaccess文件
-
$ sudo touch /var/www/html/wordpress/.htaccess
-
$ sudo chown www-data:www-data /var/www/html/wordpress/.htaccess
-
$ sudo chmod 664 /var/www/html/wordpress/.htaccess
10.用浏览器打开, 一步一步安装WP;
11.踩坑
问题1:Could not get lock /var/lib/dpkg/lock解决方案
ps -A | grep apt
sudo kill -9 processnumber
问题2:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ps -A|grep mysql
12.显示类似:1829 ? 00:00:00 mysqld_safe 1876 ? 00:00:31 mysqld
kill -9 1829
kill -9 1876