วิธีติดตั้ง Wordpress ในหลาย Sub Damain ให้ใช้ Database อันเดียวกัน
เรื่องจากผมได้แบ่ง Domain thaiembedded.com ออกเป็น 3 Subdomain แล้ว database ใน DirectAdmin ของผมให้ใช้ Database ได้แค่ 3 ตัว ผมเลยหาทางติดตั้ง Wordpress โดยให้ทั้ง 3 Subdomain ใช้ Database ร่วมกัน
1. เปิดไฟล์ wp-config-sample.php ขึ้นมา
define(’DB_NAME’, ‘putyourdbnamehere‘); // The name of the database
define(’DB_USER’, ‘usernamehere‘); // Your MySQL username
define(’DB_PASSWORD’, ‘yourpasswordhere‘); // …and password
define(’DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value
define(’DB_CHARSET’, ‘utf8′);
define(’DB_COLLATE’, ”);
// Change each KEY to a different unique phrase. You won’t have to remember the phrases later,
// so make them long and complicated. You can visit http://api.wordpress.org/secret-key/1.1/
// to get keys generated for you, or just make something up. Each key should have a different phrase.
define(’AUTH_KEY’, ‘put your unique phrase here’); // Change this to a unique phrase.
define(’SECURE_AUTH_KEY’, ‘put your unique phrase here’); // Change this to a unique phrase.
define(’LOGGED_IN_KEY’, ‘put your unique phrase here’); // Change this to a unique phrase.
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = ‘wp_1‘; // Only numbers, letters, and underscores please!
ตรงที่ทำตัวหนาก็ใส่ตามปกติ ส่วนที่เน้นสีแดงจะเป็น Table ที่เราต้องตั้งให้แตกต่างกันไป เช่น wordpress เวบแรกเป็น wp_1, wordpress เวบที่สองเป็น wp_2 ไปเรื่อย ใน 1 database อย่าแตกเป็น table เยอะนะครับ เพราะมันจะทำให้ช้า ถ้าให้ดีอย่าให้เกิน 10
2. จากนั้นก็ save ไฟล์เป็น wp-config.php เป็นอันเสร็จ
