Showing posts with label :: Web Server. Show all posts
Showing posts with label :: Web Server. Show all posts

Saturday, October 25, 2014

Migrate From Apache to Nginx (Engin X) on Ubuntu VPS

I have low end of VPS, there are has minim of spesification hardware, googling and found recommended using Nginx for web server to reduce using of memory.

1. Stop service for Apache

sudo service apache2 stop

2. Installing Nginx PHP5-FPM

sudo apt-get install nginx php5-fpm

3. Configure PHP5-FPM

need to configuring PHP5 handler by Nginx
sudo nano /etc/php5/fpm/php.ini
find (CTRL + W) cgi.fix_pathinfo word and set like the below value:
cgi.fix_pathinfo=0
will modify another PHP configuration
sudo nano /etc/php5/fpm/pool.d/www.conf
find the "listen = ", We will modify this to use a socket for communication with the web server
listen = /var/run/php5-fpm.sock
Restart the PHP-FPM
sudo service php5-fpm restart

5. Set the Vhost of Nginx

sudo nano /etc/nginx/sites-available/myvhost.conf
add this lines to configure your site, for more example script you can find at /etc/nginx/sites-available/default
server {
    listen 80;

    root /var/www;
    index index.php index.html index.htm;
}
unlink the default configuration
sudo unlink /etc/nginx/sites-enabled/default 
Start the Nginx web server
sudo nano service nginx start

6. Remove Apache

to find all dependcies of Apache you filter like this:
dpkg --get-selections | grep apache
will display:
apache2      install
apache2-doc     install
apache2-mpm-prefork    install
apache2-threaded-dev    install
apache2-utils     install
apache2.2-bin     install
apache2.2-common    install
libapache2-mod-auth-mysql   install
libapache2-mod-passenger   install
remove
sudo apt-get remove apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-auth-mysql libapache2-mod-php5
for the clear remove dependencies run this command
sudo apt-get autoremove

Saturday, October 18, 2014

Friday, October 17, 2014

`autodetect': Could not find a JavaScript runtime on Ubuntu

When i starting the rails server, got the message " `autodetect': Could not find a JavaScript runtime "
googling and fix the issue with install a package:
sudo apt-get install nodejs

Monday, March 3, 2014

How to install Kloxo on Centos 5

If you are using Firewall, ensure port 7778 and 7777 is open, just type:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 7778 -j ACCEPT

1. Disable SELinux

sudo setenforce 0

2. Download Kloxo

mkdir /home/kloxo
cd /home/kloxo
wget http://download.lxcenter.org/download/kloxo/production/kloxo-installer.sh

3. Install Kloxo

sh ./kloxo-installer.sh --type=master

4. Access the Kloxo

After installed the Kloxo, access the url Kloxo:
http://IP_address:7778 or
https://IP_address:7777

For default login use:
username: admin
password: admin

Next you can change the password.

Sunday, March 2, 2014

How To Install Linux, Apache, MySQL, PHP on Centos 5

Firsly update packages on Centos
sudo yum update

1. Install Apache

sudo yum install httpd
sudo service httpd start

2. Install MySQL

sudo yum install mysql-server
sudo service mysqld start
You can set a root MySQL password with these command:
sudo /usr/bin/mysql_secure_installation

3. Install PHP

sudo yum install php php-mysql

   PHP Modules

You can see the libraries that are available by typing:
yum search php-
Then terminal will show list of modules:
php53-process.i386 : Modules for PHP script using system process interfaces
php53-pspell.i386 : A module for PHP applications for using pspell interfaces
php53-snmp.i386 : A module for PHP applications that query SNMP-managed devices
php53-soap.i386 : A module for PHP applications that use the SOAP protocol
php53-xml.i386 : A module for PHP applications which use XML
php53-xmlrpc.i386 : A module for PHP applications which use the XML-RPC protocol
To see more detail:
yum info name_of_module
To install the module:
yum install name_of_module
Finally, restart your apache to see the effect for the changed:
sudo service httpd restart

Remote host identification has changed : Host key verification failed

When i try to ssh my server, something is wrong, i got warning messages:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
80:54:8b:9b:39:fb:f1:23:af:0f:4d:af:eb:24:70:44.
Please contact your system administrator.
Add correct host key in /Users/arul/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/arul/.ssh/known_hosts:1
RSA host key for 192.168.10.50 has changed and you have requested strict checking.
Host key verification failed.
That messages show up, because RSA host key had change
May be it haven after installed new Operating System
To fix this, i must delete RSA host key for IP 192.168.10.50
vi ~/.ssh/known_hosts
Done, now i can remote with SSH

How to uninstall webmin on ubuntu

Just simple way:
apt-get remove webmin
Other way to uninstall webmin
/etc/webmin/uninstall.sh .

Friday, January 3, 2014

Setup a Ubuntu VPS for Ruby on Rails Application

In this section, my VPS using Ubuntu Server OS

1. Connecting to your server


Login using SSH, as the root user
ssh root@100.100.100.100  #VPS IP Address
password: {your_password}

2. Create a new User

Add a new user to instead the root user
adduser your_username
password {enter_the_password_user}

3. Update the ubuntu

Make sure the Ubuntu is up date
sudo apat-get update

4. Install nano text editor

sudo apat-get install nano

5. Install RVM (Ruby Version Manager)

Firstly, we'll install the Curl
sudo apat-get install curl
Then, install the RVM
\curl -L https://get.rvm.io | bash -s stable
After installing is done, load the RVM. You may first need to exit out out your shell session (terminal) and start up a new one
source ~/.rvm/scripts/rvm

6. Install Ruby with RVM

First, RVM will check the dependencies to install ruby
rvm requirements
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
Now we can list all the availabel versions of Ruby that are available:
rvm list known
Will show list all Ruby version like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p484]
[ruby-]2.0.0-p195
[ruby-]2.0.0[-p353]
[ruby-]2.1.0
[ruby-]2.1.0-head
ruby-head
Select newest Ruby version and install with rvm:
rvm install 2.1.0
rvm --default use 2.1.0
Finally, you need to check installed the Ruby on your computer
ruby -v
gem -v

7. Install Rails

sudo gem install rails
Check rails version
raisl -v

Wednesday, January 1, 2014

Installing PHP5 on Ubuntu

To Install PHP, oper terminal and type in this command
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Tuesday, November 12, 2013

How to Activate an .htaccess file

Open your Vhost, and edit:
AllowOverride None
to
AllowOverride All

Saturday, September 28, 2013

Setting Virtual Host (VHost) on Mac OS X

1. Preparation

In this section i'm used local.mysite.dev for sample
Start Apache
1. Go to System Preferences
2. Select "sharing"
3. Check the box "Web Sharing" -- for starting the apache

2. Edit the Host file

For editing you can use nano or mate text editor for command line
sudo nano /etc/hosts
or
sudo nano /private/etc/hosts
You can see the following codes:
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
add new host local.mysite.dev at end of line
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       local.mysite.dev


3. Switch in the httpd.conf file

sudo nano /etc/apache2/httpd.conf
find the "# Virtual hosts" string using ctl + w and type "# Virtual hosts" without (")
# Virtual hosts 
#Include /private/etc/apache2/extra/httpd-vhosts.conf
un comment the code to enable the VHost
# Virtual hosts 
Include /private/etc/apache2/extra/httpd-vhosts.conf


4. Add virtual host in apache

sudo nano /private/etc/apache2/extra/httpd-vhosts.conf
add these codes:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any  block.
#
                                                                                                   
< VirtualHost *:80>
  ServerName localhost
  DocumentRoot "/Library/WebServer/Documents"
< /VirtualHost>

< VirtualHost *:80>
  ServerAdmin local@mysite.dev
  DocumentRoot "/Library/WebServer/Documents/mysite/webroot/"
  ServerName local.mysite.dev
    < directory "/Library/WebServer/Documents/mysite/webroot/">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
    < /directory>
  ErrorLog "/private/var/log/apache2/local.mysite.dev.com-error_log"
< /VirtualHost>


5. Restart Apache

finally, restart the Apache
sudo apachectl restart
Open your browser the type the url (http://local.mysite.dev) --for example

Thursday, May 2, 2013

Turn off warnings and notice on PHP on Mac







To clear this issue, follow the step:
sudo cp -rf /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini
then find and edit error_reporting
CTRL+W to find error_reporting module the change that code like the bellow line:
error_reporting = E_ALL & ~E_NOTICE
Restart your apache
sudo apachectl restart
that's all, reload your page.

Forbidden You don't have permission to access / on this server







I got this issue on Mac Lion OS X.
to fix this issue, just simple step.. here we go

Oper your terminal and type:
sudo nano /etc/apache2/extra/httpd-vhosts.conf 
add these line of codes:
< VirtualHost *:80>
   DocumentRoot "/Library/WebServer/Documents"
< /VirtualHost>
Restart your apache
sudo apachectl restart

Friday, February 18, 2011

Installing Apache2 with PHP5 and MYSQL support

Open your terminal and enter the following command to start installation

1. Installing Apache2
sudo apt-get install apache2

2. Installing PHP5
sudo apt-get install php5 libapache2-mod-php5

3. Installing MYSQL
sudo apt-get install mysql-server mysql-client
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin

Monday, July 26, 2010

resolve "ActionController::RoutingError (No route matches "/favicon.ico" with {:method=>:get}):" log message

How to resolve this case.. i think when access the site, browser should be found the favicon.ico in public/ directroy. ok you just place the "favicon.ico" in the public/ directory
hope helpful :)

Wednesday, July 7, 2010

deploy with Capistrano raise "Symbolic link not allowed or link target not accessible:" when access on site using SUSE 11.1 Linux

When i'm deploying my project to server, i can't access the site (Forbidden Access) then i check the log file at > tail -f /var/log/apache2/error_log
there are raise something like this "Symbolic link not allowed or link target not accessible:". I had tried everything, change owner, change permissions, set "Options FollowSymlinks" in my Vhost conf.. etc, but it didn't work.

Next, i'm checking conf at httpd.conf.. wahh there are got thing wrong script, like the following.

> vi /etc/apache2/httpd.conf



# forbid access to the entire filesystem by default
<directory>
    Options None 
    AllowOverride None
    Order deny,allow
    Deny from all
</directory>

"Options None", it's should be "FollowSymlinks".
Well, the solution i must change a line script below:

# forbid access to the entire filesystem by default
<directory>
    Options FollowSymlinks
    AllowOverride None
    Order deny,allow
    Deny from all
</directory>

Final, next i just to restart my server

> /etc/init.d/apache2 restart

It's All.. hope helpful.

Tuesday, July 6, 2010

Configure passenger on SUSE 11.1 Linux

Intall require package, following:

> yast2 -i gcc gcc-c++ make automake git ruby ruby-devel rubygems mysql mysql-client libmysqlclient15 libmysqlclient-devel ruby-mysql zlib gzip unzip memcached ImageMagick ImageMagick-devel ruby-RMagick ruby-RMagick-doc libxml2 libxml2-devel libxslt libxslt-devel yaz libyaz-devel idzebra idzebra-devel curl libcurl-devel libreadline5 readline-devel apache2 apache2-devel 

> yast2 -i wv wv-devel poppler-tools libpoppler4 poppler-data lynx


> yast2 -i libexif exiftool


Install passenger (follow the wizard intructions).

> passenger-install-apache2-module


Put these lines to end of file in httpd.conf, edit the file at /etc/apache2/httpd.conf

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9
PassengerRuby /usr/local/bin/ruby


Add a Vhost and locate them to your doc apps

> vi /etc/apache/vhosts.d/filename.conf (will create new file, if not exist)

add these line

<VirtualHost *:80> 
  ServerName www.yourdomain.com
  ServerAlias your_alias_name.com
  DocumentRoot /app_path/public
  RailsEnv production
  <Directory /app_path/public>
    Options Indexes FollowSymLinks
    Options -MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


well, now we just to restart the apache server.

> /etc/init.d/apache2 restart

Thursday, February 11, 2010

Installing Phusion Passenger

Phusion Passenger is an apache modul, it's enable Ruby application work in apache which you can deploying your Rails applications and manage it.

In these intructions i'm used Ubuntu Linux operating system, follow this steps:

open the terminal and type

> sudo gem install passenger
> sudo passenger-install-apache2-module


you would see the wizard installation, follow the instructions step by step :)

now, passenger is installed.

Adding these lines to apache conf

LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.9
PassengerRuby /usr/local/bin/ruby



copy and paste in this location

> sudo nano /etc/apache2/apache2.conf

put that at the bottom and save

> sudo apache2ctl -k restart OR sudo /etc/init.d/apache2 restart

restart your apache

adding new IP addresses for every app as you want to add, in this location

> sudo nano /etc/hosts

127.0.0.1       localhost
127.0.1.1       arul-laptop

127.0.0.2       sgm.local

127.0.0.3       extranet.gamestreamer.rails
127.0.0.3       admin.gamestreamer.rails
127.0.0.3       games.gamestreamer.rails
* in this case i'll use the SGM (my project applications) to guide

add a virtual host to your apache congfiguration

> sudo nano /etc/apache2/sites-available/sgm

<VirtualHost 127.0.0.2:80>
ServerName sgm.local
DocumentRoot /home/arul/Documents/41studio-projects/SGM/public
RailsEnv development
RailsBaseURI /
<Directory "/home/arul/Documents/41studio-projects/SGM/public/">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
* add "public" directory of end your app locations

> ls -l /etc/apache2/sites-available

showing the site available now

> ls -l /etc/apache2/sites-enable
showing the site enabled now, you can enabled the site which you must make the simbolic link from sites-available to sites-enable directory in apache configuration

> sudo ln -s  /etc/apache2/sites-available/sgm  /etc/apache2/sites-enable/
you can undo that symlink with "sudo unlink" command

> ls -l /etc/apache2/sites-enable
> sudo /etc/init.d/apache2 restart
now, we have successfully configuration the site

you can check it out, open your browser and point this http://sgm.local (it's mine)

actually, to configure that's have shortcut way.. follow this steps

after you made the virtual host, you can automatically configure with this command and restart your apache webserver :)

> sudo a2ensite sgm
> sudo /etc/init.d/apache2 restart