Archive

Archive for the ‘Linux’ Category

How to install WordPress on CentOS

February 1, 2012 5 comments

1. Make sure LAMP is ready

2. Download wordpress latest version

# cd ~/tmp

# wget http://wordpress.org/latest.zip

Current version is 3.3.1.

3. Extract the zip file and move to host folder

# unzip latest.zip

# mv wordpress /var/www/html/wp

# chown -R apache:apache /var/www/html/wp             ————— change the owner as “apache”

4. Create a database for wordpress

mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'my-password';
mysql> FLUSH PRIVILEGES;


4. Set up configure file

# cd /var/www/html/wp
# cp wp-config-sample.php wp-config.php
# vi wp-config.php


Replace following as yours:
database_name_here --> database name, such as "wordpress"
username_here -------> database user name, for instance "wp1"
password_here -------> database password, eg. "mypassword"

5. Start installation from web

http://192.168.1.1/wp/wp-admin/install.php

And then, follow the page to setup site information.

Categories: CentOS, Wordpress

Switch between log in managers

January 31, 2012 Leave a comment

There are a couple of log in managers in Ubuntu, such as gdm, lightdm. kde.

Switching between these log in managers is easy:

$ sudo dpkg-reconfigure gdm

And then select a log in manager in the popup window.

Categories: gnome, Ubuntu

Install tightVNC on Ubuntu server

January 29, 2012 Leave a comment

1. Make sure Ubuntu desktop is ready

2. Install tightvnc server

$ sudo apt-get install tightvncserver

3. Test vnc client

Launch tightvnc or ultravnc viewer, and input server as “192.168.1.101:1”

4. Start up applications with vnc client log in

Put all application start up commands in ~/.vnc/xstartup.

5. Create a booting script

$ sudo vi /etc/init.d/vncserver

———————– vncserver begin —————————

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
PATH=”$PATH:/usr/X11R6/bin/”# The Username:Group that will run VNC
export USER=”vncuser”           # The user to start vnc
#${RUNAS}# The display that VNC will use
DISPLAY=”1″    # user display number 1

# Color depth (between 8 and 32)
DEPTH=”16″

# The Desktop geometry to use.
#GEOMETRY=”<WIDTH>x<HEIGHT>”
#GEOMETRY=”800×600″
GEOMETRY=”1024×768″
#GEOMETRY=”1280×1024″

# The name that the VNC Desktop will have.
NAME=”vnc-server”

OPTIONS=”-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}”

. /lib/lsb/init-functions

case “$1” in
start)
log_action_begin_msg “Starting vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver ${OPTIONS}”
;;

stop)
log_action_begin_msg “Stoping vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver -kill :${DISPLAY}”
;;

restart)
$0 stop
$0 start
;;
esac

exit 0

———————– vncserver end ———————

6. Change the script to excutable

$ sudo chmod +x vncserver

7. Set up vncserver auto start and stop with system start up and shutdown

$ sudo update-rc.d vncserver defaults     # change the “defaults” to ” defaults 99″ if want it run or stop as the last script

eg.

$ sudo update-rc.d vncserver -f remove

$ sudo update-rc.d vncserver defaults 99

Categories: Ubuntu

Install VNC on Ubuntu server

January 29, 2012 Leave a comment

In order to remote log in via the graphic desk to Ubuntu server, a installation of VNC is needed. Following demonstrate  the detailed steps for VNC setting on Unbuntu.

1. Make sure Gnome or other x-window is ready on Ubuntu

2. Install VNC server on Ubuntu

$ sudo apt-get install vnc4server

3. Set up a VNC password for current user, this password is needed while connect VNC client

$ vncpasswd

4. Set up a display number

$ vncserver :1

This would create necessary files for VNC server.

VNC clinet log in need to input “192.168.1.100:1”. The number “1” is the display number.

5. Set up Gnome for VNC log in

5.1 Shutdown VNC server

$ vncserver -kill :1

5.2 Set up xstartup file for current user

$ cd

$ cd .vnc

$ vi xstartup

——- xstartup ———

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &               # comment this line
# x-window-manager &                  # comment this line
gnome-session &                        # add this line, for gnome only

———————- xstartup ——————

5.3 Restart vncserver

$ vncserver :1

6. vnc client log in error

Failed to load session “Ubuntu”

This message is because the problem of desktop installation. Use “apt-get install ubuntu-desktop” to reinstall the graphic desktop.

Categories: Ubuntu

yum install gnome for CentOS

January 28, 2012 Leave a comment

Minimum installation of CentOS server would not include any x-windows, but you could install gnome.

1. Verify group components installed

# yum grouplist

2. Install x-window

# yum groupinstall “X Window System”

3. Install Gnome

# yum groupinstall “GNOME Desktop Environment”

 

4. Remove Gnome

# yum groupremove “GNOME Desktop Environment”

 

5. Start Gnome

# startx
Categories: CentOS

Set password for root in Ubuntu

January 28, 2012 Leave a comment

Password for root is not set by default, so the command “su -” would not work.

3 approaches to work as root:

1. sudo -i

2. sudo bash

3. sudo -s

Then change the root password:

passwd

OR directly change root password as:

$ sudo passwd root

Disable root:

$ sudo -dl root

 

Categories: root password

Install Gnome on ubuntu server

January 27, 2012 Leave a comment

1. Auto install

sudo aptitude install ubuntu-desktop

OR

sudo apt-get install ubuntu-desktop

This would install Ubuntu Unity graphic desktop.

 

2. Manual install

2.1 Install x-windows core

sudo apt-get install x-window-system-core

2.2 Install gnome core

sudo apt-get install gnome-core

2.3 Install gdm (option)

sudo apt-get install gdm

2.4 Install synaptic (option)

sudo apt-get install synaptic

2.5 Remove gnome

sudo apt-get –purge remove liborbit2

2.6 Start gnome

startx

2.7 Exit gnome

ctrl + alt + backspace

sudo apt-get install synaptic

2.8 Note

If the server is on Vmware virtual server, the vmware-tools is needed; and gcc compiler is needed for vmeare-tools installation.

Categories: gnome, Ubuntu

postfix permission denied

January 24, 2012 1 comment

Issue:

1. Joomla create user error according to email

2. /var/log/httpd/error_log

sendmail: fatal: chdir /var/spool/postfix: Permission denied

Solution:

1. Verify postfix running:

# service postfix status

2. Check httpd sendmail permission

# getsebool httpd_can_sendmail

Returned:

httpd_can_sendmail --> off

3. Turn permission on

# setsebool httpd_can_sendmail 1

4. Turn permission on permanently, even reboot

# setsebool -P httpd_can_sendmail 1

 

Categories: email, postfix

vi

January 13, 2012 Leave a comment

1. Command

  • :n —> to the next edited file
  • :# —> to the alternate file
  • :n file1 —> new list
  • :r!cmd —> run a command and insert into current cursor
  • :e file2 —> go to file2
  • :e! —> reload the file
Categories: vi

Umask and sticky bit

January 9, 2012 Leave a comment

1. File and directory permission

rwxrwxrwx    — 777

r — 4

w — 2

x — 1

ugoa — user, group, other, all

2. Set umask

Preset the permission for files and directories to be created.

# umask    — show the umask value

777 – umask  —> for directories

777 – umask – 111 —> for files

3. Set sticky bit

  • SUID — 4, GUID –2, Sticky — 1
  • Sticky bit — a “t” at the end of others, for the directories, only the owner can delete files under that directories

— if “x” missing, “t” becomes “T”

# chmod 1777 dir1

# chmod +t dir2

# chmod o+t dir3

  • SUID — a “s” at the end of owner, for script, who run the script would act as the script owner

— if “x” missing, “s” becomes “S”

# chmod 4777 file1

# chmod u+s file1

  • SGID — a “s” a the end of group, for files. action as the group users

— if “x” missing, “s” becomes “S”

# chmod 2777 file1

# chmod g+s file2

Categories: Permission