官术网_书友最值得收藏!

Installing WordPress through a hand-built configuration file

Now, in some cases, your web hosting account will prevent WordPress from creating a valid configuration file. This issue may be caused by access rights limitations. However, it's not a big obstacle because you can always create a configuration file manually. To do this, just open the wordpress folder and find the file named wp-config-sample.php. Make a copy of this file and rename it wp-config.php. We'll modify this file together.

You need not be a PHP programmer to do this. Just open this file with a simple editor such as Notepad. The following is the copied text from the original wp-config.php file. One thing to know about PHP is that any text that comes after a double slash (//), or between a slash-star and star-slash (/* and */), is a comment. It's not actual PHP code. Its purpose is to inform you what that line or that section is about. With that said, note that most of the comments have been removed, so that we can focus on the items we need to change.

<?php 
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here'); 
 
/** MySQL database username */
define('DB_USER', 'username_here'); 
 
/** MySQL database password */
define('DB_PASSWORD', 'password_here'); 
 
/** MySQL hostname */ 
define('DB_HOST', 'localhost'); 
 
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');
 
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
 
define('AUTH_KEY', 'put your unique phrase here'); 
define('SECURE_AUTH_KEY', 'put your unique phrase here'); 
define('LOGGED_IN_KEY', 'put your unique phrase here'); 
define('NONCE_KEY', 'put your unique phrase here'); 
define('AUTH_SALT', 'put your unique phrase here'); 
define('SECURE_AUTH_SALT', 'put your unique phrase here'); 
define('LOGGED_IN_SALT', 'put your unique phrase here'); 
define('NONCE_SALT', 'put your unique phrase here'); 
 
$table_prefix  = 'wp_'; 

As you can see from the code, you can insert a number of settings here, but they do resemble the ones we were filling out in the online installer just a minute ago. Let's walk through the most important ones.

Just as in the online installation, we fetched the database information, but this time we put it in the wp-config.php file:

// ** MySQL settings ** // 
define('DB_NAME', 'wptestblog');   
define('DB_USER', 'localdbuser');   
define('DB_PASSWORD', '62dcx%^_0hnm'); 
define('DB_HOST', 'localhost'); 

Next, for security purposes, you need to put some unique phrases into what's called the WordPress salt keys. These secret keys are used by WordPress to add random elements to your passwords and in some other situations. This will help to keep your WordPress installation uniquely protected. No one else is likely to choose the same unique keys that you chose, and therefore, breaking or hacking into your site will be more difficult. You can get some secret keys generated from https://api.wordpress.org/secret-key/1.1/salt/ (the sample config file itself will remind you of this through the in-code PHP comments). Once you have finished, you will get the following code snippet, which you can paste directly into the default code in wp-config.php:

define('AUTH_KEY', 'uu|6#00Pc/3h?Pg5:Zc#:S=;<3mdw-ai'); 
define('SECURE_AUTH_KEY', 'vy1.@Nr@Zb^G|0Vfz-|TH5&W'); 
define('LOGGED_IN_KEY', 'sryMVd'jVpiMWWQqx~!v XE5@fJMTt2[Z'); 
define('NONCE_KEY', 'i,+UPpMR>Mj3o}(B**^<T:/md,YFF76d]Kf'); 
define('AUTH_SALT', 'n.8Li=9OjV+_p|}e5yN2k<s{!KJs|[S&Zh'); 
define('SECURE_AUTH_SALT', 'I#2vPT^u[5vLX|'MzPg/J*y]RTfr'); 
define('LOGGED_IN_SALT', 'gR%QP^c*jfFUy,iQ}-0g_%;%H)pN0B5'); 
define('NONCE_SALT', '&L);.IH'v{]zYLO2:h_t#J0D-p)cvyc'); 
Important!
Don't ever get the salt keys from anywhere other than https://api.wordpress.org/secret-key/1.1/salt/. This is an important security mechanism that protects your browser session from being hijacked and then used for unauthorized access to your WordPress site.

Finally, we have the aforementioned table prefix. The wp-config.php file allows us to set this, too. Again, here's the prefix of our choice:

$table_prefix  = 'wp_'; 

The WordPress Codex has a long and detailed page that describes everything about editing your wp-config.php file: https://codex.wordpress.org/Editing_wp-config.php. Once you save the wp-config.php file and either upload it to your web host or place it on your local server, you can visit your site through your domain name (like http://yoursite.com/). You should be presented with the final setup page, the one visible in the earlier screenshot. All you have to do now is proceed according to the instructions described earlier in this chapter.

主站蜘蛛池模板: 永定县| 洱源县| 浪卡子县| 通江县| 辽阳市| 永兴县| 河南省| 铜陵市| 昌图县| 屏山县| 奉贤区| 松桃| 云浮市| 依安县| 陇西县| 田阳县| 汪清县| 普格县| 额尔古纳市| 兖州市| 阿巴嘎旗| 凤冈县| 漠河县| 瑞昌市| 黎平县| 光泽县| 屏山县| 阜康市| 阿拉善左旗| 漳浦县| 罗田县| 贞丰县| 宜城市| 田阳县| 辉县市| 博爱县| 荥阳市| 于都县| 普陀区| 灵璧县| 米易县|