WordPress记录

安装

Introduction
The LAMP server is the cornerstone of Linux web hosting. In the early days of dynamic web content LAMP was what won Linux the crown in the web space, and it still is responsible for powering a very large portion of the Internet's sites.

If you're looking to set up a LAMP stack to host your website, it'd be hard to find a better option to build it on than Debian Stretch. Debian is, after all, well known for its stability, security, and massive package repositories, and Stretch is certainly no exception.
MariaDB(MySQL)
To get started, install and setup the database portion of the stack, MariaDB. Traditionally, the "M" in LAMP stands for MySQL. However, MariaDB is a drop-in replacement that isn't controlled by Oracle, so it tends to be a better option.

To install MaridaDB on Stretch, just use apt to install the packages.

apt install mariadb-client mariadb-server

During the install process, you will be prompted to create a root password for MariaDB. Make sure to choose something as secure as possible, since it will determine, in part, the security of your databases.

Now that the MariaDB server is installed, you can log in as your root user and set up a regular user and a database.
mysql -u root -p
MariaDB will then prompt you for the root password that you just set up.

Creating a database is fairly simple. Just run the following.
CREATE DATABASE newdb;
You need to create a regular user now to use the database. It is an absolutely terrible idea to use the root user for anything other than managing MariaDB as a whole.
CREATE USER 'username'@'localhost' IDENTIFIED BY 'userpassword';
That command creates a regular user that can sign in locally and set that user's password.

In order for that user to be able to use the database that you just created, you need to grant them privileges on it. Since this is a general purpose user for managing everything on this database, it will be given all privileges.
GRANT ALL PRIVILEGES ON newdb.* to 'username'@'localhost';
Once that's done, flush all privileges from the console and exit.
FLUSH PRIVILEGES;
quit
That's all for the database. Certainly, you can customize any portion of this as you need.

PHP
The next step in getting the LAMP server set up is installing PHP. In the LAMP stack, PHP powers the web content and interacts with the database. To install PHP on Debian Stretch, run the following line.

apt install php7.0 php7.0-mysql

That's really all that you need. PHP is now ready to use.
Apache
The Apache web server is extremely powerful and can be extremely easy to set up or ridiculously difficult, depending how in-depth you wan to go. Because this is just a simple guide, it's going to follow the quickest path for getting a basic server set up.

So, install both the Apache server and the module for PHP support.

apt install apache2 libapache2-mod-php7.0

Testing Your Server
By default, Apache will server the contents of /var/www/html and will look first for a file called index.php or index.html. Create that file, and place the following line of code in it.
<?php phpinfo(); ?>
Open up your browser and type in localhost in your address bar. If you aren't doing this locally, type your domain name or IP. You should see a long table containing information about your PHP install. At this point, your sever is officially working.

If you want an easy way to manage your database through a graphical web interface, you can install an application called, phpmyadmin. It allows you to manage your database using PHP through your LAMP server. To install it on Stretch, just pull it with apt.

apt install phpmyadmin

Once the package installs, you can navigate in your browser to localhost/phpmyadmin You will be greeted with a login screen that will accept your database credentials and finally, an interface to work with your database.
Closing Thoughts
Your LAMP server is now ready to go. Of course, there are tons of other options, and if you plan to use this as a public facing server, you may want to look into more security options for Apache. That said, this LAMP server can run everything from your custom PHP application to popular solutions like WordPress and even development frameworks like Laravel.
Create Your Database
Once your server is ready, you can set up the database where you're going to store everything from WordPress. Log in to MariaDB as your root user.

mysql -u root -p

Once you're signed in, create a regular user for WordPress.
MariaDB [(none)]> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'userpassword';
Now, create your WordPress database.
MariaDB [(none)]> CREATE DATABASE wp_database;
Finally, grand your user all permissions on the database.
MariaDB [(none)]> GRANT ALL ON wp_database.* TO wpuser@localhost;
Flush your privileges and exit.
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Download And Unpack WordPress
Here's where WordPress makes its entrance. You can either head over to the
https://wordpress.org and download it that way, or just use wget. The URL never changes, so wget will always work.
cd Downloads wget https://wordpress.org/latest.tar.gz
Unpack WordPress using tar.
$ tar xpf latest.tar.gz
The resulting folder will be wordpress. It contains the entire WordPress install. How and where you copy it is entirely up to you and depends on your web server configuration. The example provided covers the most basic possible install on Apache.

rm -rf /var/www/html

cp -r wordpress /var/www/html

If you're using Nginx, you probably just want to place the folder in /var/www/ as it is, and point your configuration at it. When WordPress is where you want it, change the permissions and ownership to improve security and grant your webserver proper access.

chown -R www-data:www-data /var/www/html

find /var/www/html -type d -exec chmod 755 {} ;

find /var/www/html -type f -exec chmod 644 {} ;

Certainly, if your webserver is configured to run under a different user, change the ownership to that one.
WordPress Setup
ip:port/wp-admin/install.php进入WordPress安装界面。


image.png

WordPress's web-based installer handles the rest of the process. So, open up a web browser and navigate to the domain name or IP address of your server.


image.png

The first screen that you'll see will just greet you. When you click through to the next screen, WordPress will prompt you for your database information. Enter everything that you set up.
image.png

The final screen will ask you for information about your site. Enter everything as it pertains to the website that you're setting up. After that screen, the WordPress installer will run and set up everything. When it finishes, it will present you with the WordPress login screen. You can then log in and gain access to your admin interface.
Closing Thoughts

Congratulations! You have a working WordPress installation on Debian Stretch. If you're running this server in production, make sure that you properly secure it, and that includes WordPress itself.

WordPress日志开启:
配置文件说明

需要修改的配置文件是WordPress根目录下的 wp-config.php 文件,记得以 UTF-8 无 BOM 格式编码。

开启调试模式

设置调试模式要修改的是 WP_DEBUG 这个常量,默认是:

define(‘WP_DEBUG’, false);
需要开启时找到这行并修改为:

define(‘WP_DEBUG’, true);
即可,false代表关闭,true代表开启。

输出调试信息

如果需要输出调试信息到日志文件(前提是开启了调试模式),在下面加一句

define(‘WP_DEBUG_LOG’, true);
即可,调试信息会被保存到 wp-content 目录下 debug.log 文件。

不在页面显示

如果并不需要在页面显示调试信息,那么你可以加上这一句

define(‘WP_DEBUG_DISPLAY’, false);
来实现。这个一般配合 WP_DEBUG_LOG 使用,即只输出日志不在页面显示。

修改静态脚本

如果你需要调试WordPress的CSS和Javascript代码,那么你可以加这一句

define(‘SCRIPT_DEBUG’, true);
来调用完整版代码(默认调用的都是压缩版,压缩版根本没法看,通常都是修改完整版代码)。

记录数据查询

如果你需要记录页面都进行了哪些数据库查询,那么你可以加这一句

define(‘SAVEQUERIES’, true);
来实现,然后读取全局变量 $wpdb->queries 就可以知道有哪些查询了。

WordPress日志输出:tailf /var/www/html/wp-content/debug.log

官方参考资料

http://codex.wordpress.org/Debugging_in_WordPress

参考链接:
https://linuxconfig.org/how-to-install-a-lamp-server-on-debian-9-stretch-linux
https://linuxconfig.org/how-to-install-wordpress-on-debian-9-stretch-linux
https://cloud.tencent.com/document/product/213/8044
域名解析

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,826评论 6 506
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,968评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,234评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,562评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,611评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,482评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,271评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,166评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,608评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,814评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,926评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,644评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,249评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,866评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,991评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,063评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,871评论 2 354

推荐阅读更多精彩内容