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

Slavik

Administrator
#1
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 XenForo.com. 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.

Introduction

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.

Prerequisites

Completed Part 2.

Installation Guide

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

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

Code:
wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.1.1/phpMyAdmin-4.1.1-all-languages.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fphpmyadmin%2F&ts=1387905632&use_mirror=kent
Code:
unzip phpMyAdmin-4.1.1-all-languages.zip
Next, move all the files into the correct place, and remove what we dont need.

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

Code:
mv config.inc.php.sample config.inc.php
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).

Code:
unzip xenforo_1.2.4_A06F265840_full.zip
Then move the files to the correct place.

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

Code:
rm -Rf upload
rm -f INSTALL-UPGRADE.txt
rm -f xenforo_1.2.4_A06F265840_full.zip

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

Code:
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.

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

So first create the database.

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

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

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

Code:
exit;



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.

Code:
group1: phpmyadmin



Save and close, then open up the htpasswd file.

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

Code:
phpmyadmin:pass123
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

Code:
extension=apc.so
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.
 
#4
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
 

Slavik

Administrator
#5
mv config.inc.php.sample config.inc.php
mv: cannot stat `config.inc.php.sample': No such file or directory
Sounds like the file name is wrong, run "ls" without the quotes to find the right file name.

when i change listener to port 80 .
it error ERRORHttpListener::start(): Can't listen at address Default: Address already in use!
ERRORHttpServer::addListener(Default) failed to create new listener
ERROR[config:server:listener (Default] failed to start listener on address *:80!

and i turn off apache and have error
ERRORInvalid rewrite directive: ErrorDocument 404 http://frivgames.xyz
ERRORInvalid rewrite directive: RewriteEngine on

i change listener to 8088 frivgames.xyz when go to apache at port 80
when i turn off apache frivgames.xyz will error
how to fix it.
You cant run both on the same port.
 
#6
Not sure what I am doing wrong, but when I try to unzip the phpMyAdmin all-languages.zip, it tells me it can't be found. I followed the wget before it as it was laid out.
 

Earl

New Member
#8
Not sure what I am doing wrong, but when I try to unzip the phpMyAdmin all-languages.zip, it tells me it can't be found. I followed the wget before it as it was laid out.
Try this:
Code:
cd /usr/local/lsws/DEFAULT/html/protected/
curl -L http://liquidtelecom.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.3.10/phpMyAdmin-4.3.10-all-languages.tar.gz | 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 http://www.phpmyadmin.net/home_page/downloads.php)
 
#9
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.

Code:
       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]
 
#10
Hello,
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
#</IfModule>

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 ^(.*)$ http://www.mydomain.com/$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]
</IfModule>

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,
maszd
 
#11
Real simple.. remove the
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
the
Code:
<IfModule>
and the
Code:
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.
 
#15
Hi Olar,

In the vhost configurations directory, e.g.
Code:
/usr/local/lsws/conf/vhosts/Example/
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,
Kevin
 
Top