Thanks to:

1. Install NGINX web-server

I choose a Basic 32-bit Amazon Linux AMI 2011.09 (AMI Id: ami-b4b0cae6) AMI running on a small instance. 1.1 Update instance, you never know:

sudo yum update

1.2 And install NGINX.

sudo yum install nginx

1.3 Enable PHP and MYSQL support

install the following packages (will install MYSQL later).

sudo yum install php php-devel php-pear php-common php-gd php-mbstring php-xml php-pdo php-mysql

1.4 Install spawn-fcgi to spawn our FastCGI processes

sudo yum install spawn-fcgi

1.5 And a start/stop php_cgi script

sudo vi /etc/init.d/php_cgi

1.6 Copy/past this thanks cea2k

1.7. Make it executable and auto start on boot

chmod +x /etc/init.d/php_cgi
chmod 755 /etc/init.d/php_cgi

chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 345 nginx on

1.8 Start the server

/etc/init.d/php_cgi start

1.9 Edit default nginx.config file

vi /etc/nginx/nginx.conf

1.10 Include the virtual host directory at the bottom

I know old apache habit you could of course also use the existing /etc/nginx/conf.d/virtual.conf

include /etc/nginx/sites-enabled/*;

1.11 And the default virtual host files

sudo mkdir /etc/nginx/sites-enabled
sudo vi /etc/nginx/sites-enabled/mysite
    #
    # NGINX default PHP CGI Config Fiele
    #
    server {
        listen       80;
        server_name  *.mysite.com *.amazonaws.com;
        root         /var/www/mysite;

        access_log  /var/log/nginx/access-mysite.log main;

        location / {
                autoindex  off;
                index  index.html index.htm index.php;
        }

        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_ignore_client_abort on;
            fastcgi_param  SERVER_NAME $http_host;
        }
    }

1.12 Create a test file in the root folder set above (make sure this folder exist):

sudo vi /var/www/mysite/test.php

1.13 And phpinfo for testing

<?php phpinfo(); ?>

1.14 Restart nginx server

sudo /etc/init.d/nginx restart

1.15 By now you should be able to access the server via the public DNS

Make sure to add amazonaws.com wildcard as servernameto the host file: http://ec2-122-248-220-5.ap-southeast-1.compute.amazonaws.com/test.php

2. Configure PHP

2.1 To make PHP fully run with MODX some changes in the php.ini file has to be made.

sudo vi /etc/php.ini

2.2 And change the following

date.timezone = Asia/Singapore

2.3 Make sure that nginx user has access

to the session file or change session.save_path = “/var/lib/php/session”

sudo chown nginx:nginx -R /var/lib/php/session

3. Install MYSQL-Server

sudo yum install mysql mysql-server php-mysql

3.1 Start the server and set the root password

sudo /etc/init.d/mysqld start
mysqladmin -u root password 'new-password'

3.2 Now you should be able to connect via the root user and the new password

mysql -u root -p

4. Install S3CMD

4.1 This is just a reminder as i will restore some backup files later:

cd /etc/yum.repos.d/
sudo wget http://s3tools.org/repo/RHEL_6/s3tools.repo
sudo yum install s3cmd

4.2 Configure S3, by setting access and secret keys.

s3cmd --configure

5. Install MODX

5.1 First we will add a new virtual host file to the NGINX server

or edit the one we created earlier mysite, just make sure there are no DNS conflics.

sudo vi /etc/nginx/sites-enabled/mysite

5.2 Copy past the below config and change mymodx.com to your domain name.

This assumes MODX will be you main root web *.mymodx.com

5.3 Create the modx database

mysql -u root -p
mysql> create database mymodx;

5.4 Now we can copy the latest backup of our MODX web application

from S3 storage or install a fresh version and make sure nginxuser has read/write access:

wget http://modx.com/download/direct/modx-2.2.0-pl2.zip
unzip ./modx-2.2.0-pl2.zip 
sudo mv ./modx-2.2.0-pl2 /var/www/mymodx
sudo chown nginx:nginx -R /var/www/mydox

5.5 And run the setup http://mysite.com/setup/

6. Install WordPress

6.1 This is almost the same sa MODX

just make sure to change the host file

sudo vi /etc/nginx/sites-enabled/wp

6. Install Redmine

I just had to install ruby as I restored, my previous Redmine version. Check this for a full Installation guide for Redmine RubyGems.

sudo vi /etc/nginx/sites-enabled/redmine

Leave a Reply

Your email address will not be published. Required fields are marked *