Phat Site Blog

MySQL 5 - Creating a Username and Assigning Permissions

by admin on Feb.15, 2009, under Server Maintenance

Here’s a quick way to get a mysql up and running with all user permissions.
CREATE USER ‘newuser’@'localhost’ IDENTIFIED BY ‘password’;
GRANT ALL ON database.* to ‘newuser’;

Leave a Comment : more...

Get Your New Server Setup with Ruby on Rails and Phusion Passenger

by admin on Feb.15, 2009, under Server Maintenance

Phusion Passenger will make your web applications run without any need to do maintenance.  Let it moderate the resources by itself!

Phusion Passenger (mod_rails/mod_rack) is an apache module that makes deployment of Ruby/Rails applications as simple as PHP applications. It does not require use of any ruby specific tools to deploy application. All you have to do is copy your source files in appropriate directories on server and your code changes will be deployed. Main advantage of passenger is it allows to deploy rails application reliably on shared hosting environment. Passenger is not available for windows.

Lets see how to install Passenger on Cent OS. Cent OS 5.1 comes with Apache 2.2.3 installed. First of all make sure Ruby, Gems, Rails and ruby development headers is installed on the system, Issue following commands as root:

yum install ruby
yum install irb
yum install rdoc
yum install ruby-devel

Installing rubygems manually because distro dependencies:
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar -zxvf rubygems-1.3.1.tgz
ruby setup.rb

If you get:
RubyGems installed the following executables:
/usr/bin/gem

RubyGems is install and let’s move on.

Now install rails gems, it might take a while:

gem install rails -y
yum install httpd-devel - this might be already installed

Now, we are ready to install passenger.  It’s actually pretty easy to setup:
gem install passenger

After installing passenger and its dependencies make sure that Apache is stopped, launch passenger installer for Apache module from command line.

passenger-install-apache2-module

This will setup Apache2, teach you to configure apache and deploy your Ruby App.  You will be given instructions to add a few lines to the apache configuration file, let’s do that now.

vim /etc/httpd/conf/httpd.conf

Look for this:
#
# The following modules are not loaded by default:
#
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule asis_module modules/mod_asis.so

And add these three lines right below it:

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

After the module is installed, go ahead and create a user app.  I’ll show you how to make one if you created a new user. Run:
su newuser
cd /home/newuser/www
rails demo

Now, log back into root and mod the directory to be read:
exit
chmod 755 /home/newuser

We need to setup the virtual host for this application.  Add these lines at bottom of file:

<VirtualHost *:80>
ServerName www.demo.com
DocumentRoot /home/newuser/www/demo/public
</VirtualHost>

Make sure DocumentRoot points to public directory of your rails application. Also add server name alias to hosts file in /etc/ folder. Now start apache server from console.

service httpd start

Your new rails application should be running now with Phusion Passenger.

3 Comments :, more...

Turn On Your Lamp - Easy Apache/PHP/MySQL Install on CentOS for Web Developers

by admin on Feb.15, 2009, under Other

vi /etc/yum.repos.d/CentOS-Base.repo
find [centosplus] and locate:
enabled = 0

change to

enabled = 1

yum install php php-mysql mysql-server php-gd postgres ImageMagick ImageMagick-devel

Now you got php, mysql, graphic manipulation, and posgres installed.

Let’s setup your MySQL:
/etc/init.d/mysqld restart - after you run this, you will get a bunch of useful text, read it!
/usr/bin/mysqladmin -u root password ‘CHANGEMETOHARDPASSWORD’
/sbin/chkconfig mysqld –level 2345 on  - lets mysql startup on reboot

Now you have PHP installed with common libraries such as image manipulation and postgres and mysql for database work.

2 Comments :, , more...

Setting up SSH for New Users

by admin on Feb.06, 2009, under Server Maintenance

Make sure you are root, let’s get cracking!

/usr/sbin/useradd username - create the user
su username
passwd username - set the password

When you log into your new created user, you will create hidden directory called “.ssh”.  In this directory, you will also create a  file called “authorized_keys”.

mkdir .ssh
cd .ssh
touch authorized_keys

You will need to generate a key from your local machine to use to authenticate when you login.  On your local machine, let’s get generating! Use command “ssh-keygen -t rsa”.  You will be prompted for a password.  This is optional.  Once completed, a public and private key will be saved in the “~/.ssh” folder.

On your remote server, you need to copy the public key information.

scp ~/.ssh/id_rsa.pub myremoteuser@11.22.33.44:~/
cat id_rsa.pub >> ~/.ssh/authorized_keys
rm id_rsa.pub
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Once, you add this in, make sure the user is setup in the ‘AllowUsers’ of SS for SSH Access.  This is set in the /etc/ssh/sshd_config file.  Since you are using SSH keys, you don’t need a password anymore, so set “PasswordAuthentication yes” to “PasswordAuthentication no”.

/usr/sbin/visudo - If you want to give some sudo permissions for this user.

Leave a Comment : more...

Creating a MySQL 5.0 Database for your Web Application

by admin on Jan.25, 2009, under Server Maintenance

> mysql -u root -p
Enter password: <enter your password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database newdb;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON newdb.* TO newdbuser@localhost IDENTIFIED BY ‘password_for_newdbuser’;

To test if it’s created, run this command:
> mysql -u newdbuser -p
Enter password: <enter your password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Server version: 5.0.45 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| newdb              |
+——————–+
3 rows in set (0.00 sec)

mysql> use newdb;
Database changed
mysql> exit
Bye

Everything looks good!  Your database is created! Now you’re ready to create your Wordpress blog, just configure the settings with your database name, username, and password. ;-)

1 Comment :, more...

Installing Nginx on CentOS 5

by admin on Jan.25, 2009, under Server Maintenance

yum install pcre
yum install pcre-devel
yum install openssl-devel
yum install zlib
tar xzvf nginx-0.X.XX.tar.gz (get latest stable version)
yum install gcc
./configure –sbin-path=/sbin/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid –with-http_ssl_module –with-md5=auto/lib/md5 –with-sha1=auto/lib/sha1
make
make install

This will get you off with a nginx server.  Then, you have to configure your conf file and setup some start-up scripts, etc.

Leave a Comment :, , , more...

Creating a New User in CentOS 5

by admin on Jan.25, 2009, under Server Maintenance

Creating a New User in CentOS 5

1. SSH to your server as root
2. Create a user:  /usr/sbin/useradd newuser
3. Expire ther user immediately: /usr/bin/chage -d 0 newuser
4. Set blank password: /usr/sbin/usermod -p “” newuser
5. If you want to set the user’s password:
* su newuser
* passwd
Changing password for user newuser
New UNIX password: <enter your password>
Retype new UNIX password: <enter your password>
passwd: all authentication tokens updated successfully.

That’s it!  From there on, you have a user that can be used to host your website or blog!

Leave a Comment :, , more...

Yay!

by admin on Jan.25, 2009, under Other

This blog is setup mostly for my documentation purposes so when I setup servers or do web development that I have a central place to lookup common tasks.  If I find anything cool and interesting, I’ll post it here too.  Feel free to add comments or questions on anything on the blog though.  I’ll try to keep everything easy-to-understand and technical at the same time.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...