Server Setup Guide Part 3 (CentOS, OpenLiteSpeed, Percona) (With Pictures!).

Discussion in 'OpenLiteSpeed Tips and Guides' started by Slavik, Dec 30, 2013.

  1. Slavik

    Slavik Administrator

    Pre-Word and Disclaimer
    This guide may not be published, broadcast, rewritten or redistributed in whole or part with out the express written permission of Slavik at The author takes no responsbility for any steps, in part, or in whole, undertaken by users of this guide and does not guarantee against any losses, material or otherwise.


    In Part 2 of this guide you installed PHP, did some basic MySQL configuration, configured LiteSpeed to serve files on port 80, and set up basic IP Tables.

    In Part 3, we will install PhpMyAdmin in a secured location, install XenForo, and enable APC's opcode caching.


    Completed Part 2.

    Installation Guide

    So lets start off with installing PhpMyAdmin. First in putty lets go to the protected folder we will use.

    cd /usr/local/lsws/DEFAULT/html/protected
    Then grab PhpMyAdmin, and unzip it.

    Next, move all the files into the correct place, and remove what we dont need.

    mv phpMyAdmin-4.1.1-all-languages/* /usr/local/lsws/DEFAULT/html/protected
    rm -f
    rm -Rf  phpMyAdmin-4.1.1-all-languages
    Next, turn on the default PhpMyAdmin settings.

    You can now open your browser and navigate to http://YOURSERVERIP/protected/index.php

    When prompted enter the username "test" and the password "test123" which will allow you in to the main login screen. From here, log into PhpMyAdmin using the username root, and the MySQL password you chose in part 1 of the guide.


    Now lets install XenForo. In WinSCP navigate to /usr/local/lsws/DEFAULT/html

    In this directory you can clean it up by deleting the blocked directory, the poweredby_openlitespeed.png and the 2 html files. Keep the phpinfo.php file for now.


    Drag a copy of your XenForo zip into the directory and then head to putty.

    Unzip your XenForo file (you will need to alter the license ID string to match your own).

    Then move the files to the correct place.

    mv upload/* /usr/local/lsws/DEFAULT/html
    And some cleanup.

    rm -Rf upload
    rm -f INSTALL-UPGRADE.txt
    rm -f

    Now to install XenForo firstly we need to set the correct permissions to the data and internal_data folder and create the config file.

    chmod 777 data
    chmod 777 internal_data
    mv library/config.php.default library/config.php

    Next lets create a database and user we can use, you can either do this via PhpMyAdmin if you prefer, or, we will do it via Putty.

    mysql -u root -p
    When promted enter your mysql password you set up previously in part 1.

    So first create the database.

    create database xenforo;
    Now create a user and give it access to the database, alter the password as required.

    grant usage on *.* to xfuser@localhost identified by 'password';
    And finally give it permissions.

    grant all privileges on xenforo.* to xfuser@localhost;
    And exit mysql


    In WinSCP navigate to /usr/local/lsws/DEFAULT/html/library and open the config.php file.

    In here edit the details to match the settings you used when creating the database and user. Save and close the file.


    In your browser, navigate to http://YOURSERVERIP/index.php and follow the on screen steps to install XenForo.

    Congratulation, your all done! Well, not quite, we still have a few quick steps to once again take care of security and other general housekeeping.

    First in your OpenLiteSpeed admin panel navigate to Configuration > Virtual Hosts and click View/Edit on the Example Virtual Host and then click General.


    Under Customized Error Pages hit delete for the 404.html file that we removed earlier (alternatively, create your own custom 404 page and config it here!)

    Confirm the delete and when the page loads back to the General Tab click edit for the "Index Files".

    On this screen alter index.html to index.php then hit Save.


    Next, click the Rewrite tab and edit "Rewrite Control" to "Enable Rewrites", hit save. Edit the "Rewrite Rules" and copy the rules from the htaccess.txt from your XenForo zip file here, hit Save.


    Next, click the Contexts tab, and delete all contexts apart from /protected/. Now edit the /protected/ context and alter the Require (Authorized Users/Groups) field from "user test" to "group group1" and enter "index.php" in the Index Files box, then hit Save.

    Once done, click Actions > Graceful Restart and click OK.


    Finally, in WinSCP, navigate to /usr/local/lsws/DEFAULT/conf and open the htgroup file.

    In here, delete everything and replace with the following, I have used "phpmyadmin" as the username I wish to access the phpmyadmin protected folder with, alter as you wish.

    group1: phpmyadmin

    Save and close, then open up the htpasswd file.

    In here, add the following, replacing pass123 with your own desired password.

    Hit save then close.


    Give it a test by going to http://YOURSERVERIP/protected/ and making sure that your new chosen username and password work.

    The final thing to do is add in APC to the server for its opcode caching capabilities.

    Simply navigate in WinSCP to /usr/local/lsws/lsphp5/lib and open up the php.ini file.

    At the top, add in

    Save, then close


    Go back to the LiteSpeed Admin Panel and perform a graceful restart. For one last time, open up http://YOURSERVERIP/phpinfo.php and check for the APC section. If it is there, then you can now delete the phpinfo.php file.


    And with that....

    We are all done!

    Congratulations :) If you made it this far, you now have a server on CentOS 6, using OpenLiteSpeed and Percona to power XenForo. You have PhpMyAdmin available if needed and password protected, and are using basic IP Tables to stop unwanted guests.

    How far you wish push your knowledge and learning from this point is up to you, but hopefully these fundamentals will be a good starting block.

    If you are a new to system administration, I would still reccomend using an experienced admin until you are completely comfortable managing your own server.

    Items not covered in these guides but reccomended include.

    Changing your default SSH port.
    Enabling SSL (especially for PhpMyAdmin)
    Renaming the vHost paths from /DEFAULT/
    Renaming the /protected/ folder to something more, obscure.
    Assigning a domain name to the server.

    So, hop to it! Go work out how to do the 5 points above.
    lsmichael and Earl like this.
  2. Earl

    Earl New Member

    Slavic you rocks! I've been waiting for this part :)
  3. OLS

    OLS Guest

    Awesome, thanks Slavic for detailing instruction.
  4. Tracy Perry

    Tracy Perry Active Member

    On my next Debian setup (which is WAY different in some manners than CentOS) I'll have to document it and ship it over to @Slavik. There are several additional items you have to install on the Debian minimal install just for compilation. Meant to do it this go around, but with the rush to set up 5 VPS's and get my forums off my old dedicated server over to the new one before I had to pay for an additional month for it I kinda "forgot". :p
  5. Slavik

    Slavik Administrator

    Sounds like the file name is wrong, run "ls" without the quotes to find the right file name.

    You cant run both on the same port.
  6. Abnormalyze

    Abnormalyze New Member

    Not sure what I am doing wrong, but when I try to unzip the phpMyAdmin, it tells me it can't be found. I followed the wget before it as it was laid out.
  7. Earl

    Earl New Member

  8. Earl

    Earl New Member

    Try this:
    cd /usr/local/lsws/DEFAULT/html/protected/
    curl -L | tar -xzv

    It will download the phpmyadmin 4.3.10 and extract to protected directory. (4.3.10 is the current latest version which can be found here
    maszd likes this.
  9. Tracy Perry

    Tracy Perry Active Member

    If specifically asking about the FURL's (Friendly URL's), this is what I use on my site that is running on OLS 1.4.3 (haven't gotten around to upgrading to the 1.4.4 again since I ran into some additional problems recently with it on a new PHP compile). I do NOT have mine in a /forum directory because then you end up with a /forums/forums when going into the threads unless you use the routes in the ACP - in addition to the fact that I don't run a CMS or landing page so all my stuff stays in the root of the site.

           RewriteCond %{REQUEST_FILENAME} -f [OR]
            RewriteCond %{REQUEST_FILENAME} -l [OR]                            
            RewriteCond %{REQUEST_FILENAME} -d
            RewriteRule ^.*$ - [NC,L]                                          
            RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml) - [NC,L]
            RewriteRule ^.*$ index.php [NC,L]
    Earl likes this.
  10. maszd

    maszd New Member

    thanks for this great tutorial, its working fine on my testing vps but when i login on OpenLiteSpeed admin panel i see this error log :

    iam use xenforo 1.4.5 with this RewriteRule on .htaccess
    # Mod_security can interfere with uploading of content such as attachments. If you
    # cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    # SecFilterEngine Off
    # SecFilterScanPOST Off

    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default

    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]
    RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
    RewriteRule ^viewtopic\.php$ /threads/%2? [L,R=301,NC]
    RewriteCond %{QUERY_STRING} f=(\d+)$ [NC]
    RewriteRule ^(viewforum\.php|viewtopic\.php)$ /forums/%1? [L,R=301,NC]
    RewriteCond %{QUERY_STRING} (^|&)p=([0-9]+)(&|$) [NC]
    RewriteRule ^viewtopic\.php$ /posts/%2? [L,R=301,NC]

    # If you are having problems with the rewrite rules, remove the "#" from the
    # line that begins "RewriteBase" below. You will also have to change the path
    # of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    # This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

    also i see this a server error logs on xenforo admin panel
    ErrorException: fopen(/usr/local/lsws/DEFAULT/html/internal_data/sitemaps/sitemap-1424689606-1.xml): failed to open stream: Permission denied - library/XenForo/Deferred/Sitemap.php:210
    Generated By: Unknown Account, 12 minutes ago
    Stack Trace

    #0 [internal function]: XenForo_Application::handlePhpError(2, 'fopen(/usr/loca...', '/usr/local/lsws...', 210, Array)
    #1 /usr/local/lsws/DEFAULT/html/library/XenForo/Deferred/Sitemap.php(210): fopen('/usr/local/lsws...', 'a')
    #2 /usr/local/lsws/DEFAULT/html/library/XenForo/Deferred/Sitemap.php(230): XenForo_Deferred_Sitemap->_openFile()
    #3 /usr/local/lsws/DEFAULT/html/library/XenForo/Deferred/Sitemap.php(202): XenForo_Deferred_Sitemap->_writeSitemapString('\t<url><loc>http...')
    #4 /usr/local/lsws/DEFAULT/html/library/XenForo/Deferred/Sitemap.php(165): XenForo_Deferred_Sitemap->_writeResult(Array)
    #5 /usr/local/lsws/DEFAULT/html/library/XenForo/Deferred/Sitemap.php(90): XenForo_Deferred_Sitemap->_buildSitemap(Object(XenForo_SitemapHandler_Core), 0, 7.9985630512238)
    #6 /usr/local/lsws/DEFAULT/html/library/XenForo/Model/Deferred.php(294): XenForo_Deferred_Sitemap->execute(Array, Array, 7.9985630512238, '')
    #7 /usr/local/lsws/DEFAULT/html/library/XenForo/Model/Deferred.php(428): XenForo_Model_Deferred->runDeferred(Array, 7.9985630512238, '', false)
    #8 /usr/local/lsws/DEFAULT/html/library/XenForo/Model/Deferred.php(373): XenForo_Model_Deferred->_runInternal(Array, NULL, '', false)
    #9 /usr/local/lsws/DEFAULT/html/deferred.php(23): XenForo_Model_Deferred->run(false)
    #10 {main}

    Request State

    array(3) {
    ["url"] => string(33) "http://mydomain/deferred.php"
    ["_GET"] => array(0) {
    ["_POST"] => array(3) {
    ["_xfRequestUri"] => string(1) "/"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"

    Any help would be appreciated
    best regards,
  11. Tracy Perry

    Tracy Perry Active Member

    Real simple.. remove the
    <IfModule mod_rewrite.c>
    RewriteEngine On
    and the
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    from the control panel where you set the rewrites for that vhost. Then restart OLS.

    Those are not needed with OLS since they are handled elsewhere in it.
    lsmichael and maszd like this.
  12. maszd

    maszd New Member

  13. Tracy Perry

    Tracy Perry Active Member

    The middle one should be the closing for the IfModule (hadn't had my tea yet). So it would be remove the </IfModule>
  14. olar

    olar New Member

    how to change user password phpmyadmin default test and test123 ?
  15. lsfoo

    lsfoo Administrator

    Hi Olar,

    In the vhost configurations directory, e.g.
    There should be a htgroup and htpasswd files. The htgroup defines which users belong to which group. The htpasswd file associates a password with a user.

    Hope this helps,

Share This Page