Showing posts with label APC. Show all posts
Showing posts with label APC. Show all posts

Wednesday, April 25, 2012

Installing Wordpress on CentOS 5.x

This is not the famous 5 minute installation, but it comes close. It takes other minor items into account, like php53 and the APC accelerator cache. I'll follow up soon with some backup scripts, but here's a baseline installation guide.

At the time of this blog entry, WordPress was up to version 3.3.2

Assumptions:
Server has a clean install of CentOS 5.x and access to the internet.

1. Login as root or su

2. Install Webserver and Database and other prerequisites
yum install httpd* mysqld* gcc* pcre-devel

3. Install php 5.3
http://noveckg.blogspot.com/2012/01/installing-php-53-on-centos-5x.html

4. Install a php accelerator
http://noveckg.blogspot.com/2012/01/installation-of-apc-on-php-53-centos-5x.html

5. Start services and configure to start on boot

chkconfig httpd on && service httpd start
chkconfig mysqld on && service mysqld start

6. Lock down mysql
/usr/bin/mysqladmin -u root password 'yourpasswordhere'
7. Create an empty wordpress database and account in Mysql
mysql -u root -p yourpasswordhere
At the mysql prompt:
CREATE DATABASE mydbname CHARSET 'utf8';
GRANT select,insert,update,delete,create,drop,index,alter
ON mydbname.*
TO mywpuser@localhost IDENTIFIED BY 'wpuserpassword';
flush privileges;
quit;

8. Download wordpress
cd /temp
wget http://wordpress.org/latest.zip
unzip latest.zip
cd wordpress
cp -r * /var/www/html/


9. Create a Wordpress data directory and assign permissions
cd /var/www/html/wp-content
mkdir uploads
mkdir cache
cd ../
chown –R apache:apache *

10. Copy default config file

cp wp-sample-config.php wp-config.php

11.    Edit config file
nano wp-config.php
Modify the following vars:
DB_NAME
The database name created in Step 7
DB_USER
The username created in Step 7
DB_PASSWORD
The password created in Step 7
DB_HOST
Localhost
(or specify remote host if applicable)

12. Open up a web browser to start WordPress config
http://my.server.ip/wp-admin/install.php

Press on..

-noveck

Tuesday, January 24, 2012

Installing Moodle 2.x on CentOS 5.7

This particular entry deals with installing (not migrating) a base Moodle 2.x installation on CentOS 5.7. A few non-standard packages were recommended at the time of writing this, so some sub-entries were made to document those steps separately.

This assumes the base installation of CentOS 5.7 has been completed and the server has connectivity to the web.

Login as root/su

Note: This installation does not default to an innodb database, As I'm a bit pressed for time at the moment, I'll either update this post, or create a new one on converting the database to innodb.



0. Update OS
yum update -y

1. Install Mysql5.5
See this post: http://noveckg.blogspot.com/2012/01/installation-of-mysql-55-on-centos-5x.html


2. Install Apache
yum install httpd*

3. Install php 5.3 
See this post: http://noveckg.blogspot.com/2012/01/installing-php-53-on-centos-5x.html

4. Install php accelerator (for performance)
See this post: http://noveckg.blogspot.com/2012/01/installation-of-apc-on-php-53-centos-5x.html



5. Download latest tarball and install into webroot
cd /temp
download moodle latest: http://download.moodle.org/download.php/stable22/moodle-latest-22.tgz
tar xzvf moodle-latest-22.tgz
cd moodle-latest-22.tgz
cp –r moodle/* /var/www/html/

6. Create empty database in MySQL

mysql -u root -p yourpasswordhere
At the mysql prompt:
CREATE DATABASE mydbname CHARSET 'utf8';
GRANT select,insert,update,delete,create,drop,index,alter
ON mydbname.*
TO mymoodleuser@localhost IDENTIFIED BY 'moodleuserpassword';
flush privileges;
quit;



7. Check web root permissions
cd /var/www/html
chown –R root:root *
chmod –R 755 *


8. Create MoodleData Folder (outside of web root)
mkdir /usr/moodledata
cd /usr/moodledata
chown -R apache:apache *
chmod –R 700 *


Note: Check here for security recommendations: http://docs.moodle.org/20/en/Security_recommendations

9. Setup Config.php
use instructions from here for a new installation: http://docs.moodle.org/21/en/RedHat_Linux_installation

10. Configure Apache to read from Moodle Data
nano /etc/httpd/conf/httpd.confAdd to end of file

[Directory "/usr/moodle/mymoodle"]*
DirectoryIndex index.php
AcceptPathInfo on
AllowOverride None
Options None
Order allow,deny
Allow from all

[/Directory]*
*substitute the [] with <> !!
11. Setup the Moodle Cron
nano /etc/crontab
add line
*/5 * * * * php /var/www/html/admin/cli/cron.php

12. Moodle!
Open up a web browser on the server and hit: http://localhost/admin
Install and configure as desired.


Happy Moodle-2-ing !

-noveck

Friday, January 13, 2012

Installation of APC on php 5.3 (CentOS 5.x)

My previous blog entry used Eaccelerator as a php cache, but it does not appear to be actively maintaned.
http://bart.eaccelerator.net/

In my research for a suitable and robust alternative, I recognized that a lot of large sites were using APC, and it was compatible with my desired application (Moodle)

APC (Alternative PHP Cache) is a free, open, and robust framework for caching and optimizing PHP intermediate code. (taken from: http://pecl.php.net/package/APC)
  
In order to avoid installation conflicts from the base repository, it was much simpler to compile the APC package from source for the php 5.3 on a CentOS 5.x installation.

0. Login as root

1. Go to temp folder and download the latest tarball cd /temp
wget http://pecl.php.net/get/APC-3.1.9.tgz


2. Extract to temp
tar xzvf APC-3.1.9.tgz
cd APC-3.1.9


3. Configure and Install
**amended on 05-07-2012, added pcre-devel install as suggested by yaroslav.

yum install pcre-devel 

phpize
./configure
make
make test
make install



4. Create APC config filenano /etc/php.d/apc.ini
Add to file

extension=apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.max_file_size = 10M
apc.stat=1

Further information on advanced tweaking of configuration items here: http://www.php.net/manual/en/apc.configuration.php
5. Restart the webserver
service httpd restart

6. Check to see if APC was installed properly
nano /var/www/html/phpinfo.php

Add to file

< php
phpinfo();
?>
 
Save and Exit

Launch from web browser: http://yourserver.com/phpinfo.php
The APC configuration item should be found on the page.

7. Install the APC monitor

Copy APC Monitoring file into web root
cp /temp/APC-3.1.9/apc.php /var/www/html/

(There are options to secure this file, see the website for further details: http://pecl.php.net/package/APC)

Check the APC monitor

Launch from web browser: http://yourserver.com/apc.php
*A page should load displaying cache information and host status.

That's it. A quick and painless method of installing the APC Cache for php 5.3 on CentOS 5.x.

-Noveck