มาติดตั้ง WordPress ให้ทำงานกับ OpenLiteSpeed เริ่มต้นด้วยทำการติดตั้ง OpenLiteSpeed ด้วยคำสั่งดังนี้
sudo apt-get update
sudo apt-get install build-essential libexpat1-dev libgeoip-dev libpng-dev libpcre3-dev libssl-dev libxml2-dev rcs zlib1g-dev
cd ~
wget http://open.litespeedtech.com/packages/openlitespeed-1.3.10.tgz
tar xzvf openlitespeed*
cd openlitespeed*
./configure
make
sudo make install
ติดตั้ง MySQL ด้วยคำสั่ง
sudo apt-get install mysql-server
สร้างฐานข้อมูลให้ WordPress ด้วยคำสั่ง
mysql -u root –p
CREATE DATABASE wordpress;
GRANT ALL ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit
ติดตั้ง PHP ด้วยคำสั่ง
sudo apt-get install libgd-dev libmcrypt-dev libcurl4-openssl-dev
เปิดเว็บเบราเซอร์แล้วไปที่ https://server_domain_or_IP:7080 แล้วทำการ Compile PHP ด้วยวิธีการดังนี้
ไปที่ Actions เลือก Compile PHP
เลือก Version ของ PHP เป็น 5.6.6 จากนั้นกดปุ่ม Next
ในส่วนของ Configure Parameters ให้ใส่ข้อมูลดังนี้
--with-mysqli --with-zlib --with-gd --enable-shmop --enable-sockets --enable-sysvsem --enable-sysvshm --enable-mbstring --with-iconv --with-mcrypt --with-mysql --with-curl --with-libdir=lib64
จากนั้นกดปุ่ม Build PHP 5.6.6 เมื่อ Build เสร็จแล้วกดปุ่ม Next
กลับมาที่ Terminal แล้วใช้คำสั่ง
sudo /usr/local/lsws/phpbuild/buildphp_manual_run.sh
เพื่อทำการ Compile ขั้นสุดท้ายรอประมาณ 5 – 20 นาที
ตั้งค่า Virtual Host ให้ WordPress
ไปที่ Configuration เลือก Virtual Hosts
กด View/Edit ในส่วนของ Example ไปที่แถบ General กด Edit ในส่วนของ Index Files
ในส่วนของช่อง Index Files ให้ทำการเพิ่ม index.php ไว้หน้า index.html จากนั้นกดปุ่ม save
เปิดการใช้งาน Permalink ของ WordPress
ไปที่แถบ Rewrite เลือก Edit ในส่วนของ Rewrite Control จากนั้นเลือก Yes ในส่วนของ Enable Rewrite จากนั้นกดปุ่ม Save
เลือก Edit ในส่วนของ Rewrite Rules แล้วแก้ไขค่าดังนี้
RewriteRule ^/index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
จากนั้นกด Save
ปิดการใช้งาน Unused Password Protection
ไปที่แถบ Security กด Delete ในส่วนของ SampleProtectedArea จากนั้นกด Yes
แล้วไปที่แถบ Context List เลือก Delete ที่ /protected/ จากนั้นกด Yes
ทำการ Restart OpenLiteSpeed ไปที่ Actions แล้วเลือกที่ Graceful Restart
กลับมาที่ Teminal แล้วทำการตั้งค่า Virtual Host และ Document Root Directories ด้วยคำสั่งดังนี้
cd /usr/local/lsws/DEFAULT
sudo rm -rf cgi-bin fcgi-bin
sudo rm conf/ht*
sudo rm -rf html/*
ติดตั้ง WordPress ด้วยคำสั่งดังนี้
cd ~
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cd wordpress
cp wp-config-sample.php wp-config.php
ทำการแก้ไขไฟล์ wp-config.php ด้วยคำสั่ง
nano wp-config.php
โดยมีเนื้อหาไฟล์ดังนี้
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'wordpressuser'); /** MySQL database password */ define('DB_PASSWORD', 'password');
คัดลอกไฟล์ทั้งหมดไปยัง Document Root ด้วยคำสั่ง
sudo cp -r ~/wordpress/* /usr/local/lsws/DEFAULT/html/
sudo chown -R nobody:nogroup /usr/local/lsws/DEFAULT/html
เปิดเว็บเบราเซอร์ไปที่ http://server_domain_or_IP:8088 จากนั้นทำการตั้งค่า WordPress เมื่อตั้งค่าเสร็จแล้ว WordPress ก็พร้อมใช้งาน