How to edit php.ini from ssh

Code Library, Linux Apache Server 2 Comments »

Type:

1. “cd /etc”
2. “ls”

Check that there is the php.ini listed if not you will have to ask your hosting provider where it is.

3. “vi php.ini”

Find the bit in php.ini you would like to edit.

4. “i” - This enables you to edit the php.ini file

5. After changing the file, please Esc.

6: “:wq” - (w = saves the file, q = quit)

7. reboot your server and your done.

Rate This Post:

Getting .htaccess to work on windows apache

Code Library, Linux Apache Server, Windows IIS Server 3 Comments »

Could figure out how to actually write the .htaccess file in windows as when i tried to rename the txt file I created to .htaccess it popped up an error saying “You must type a file name”.

The solution:

1. Open up notepad

2. Write the contents of your .htaccess

3. Save as

4. “.htacess” - Make sure you keep the speech marks.

5. Sorted

Rate This Post:

SSH Commands for FTP

Code Library, Linux Apache Server No Comments »

Ok so one of my servers is with 1and1 and they provide free backup space via ftp. However you can only access it via the server you have with them, this means logging into your server using putty (SSH) from your desktop then logging into the backup server.

To do this:
1. From a command prompt you would use the ftp command ‘ftp backup_server_name.info’
2. Enter the username, then the password.
3. Use the make directory command to create a directory: ‘mkdir
testDirectory’

The reason I wanted to make a directory is so I can automate the server backup per domain via the plesk control panel.

Rate This Post:

SSH Mysql command line

Code Library, Linux Apache Server, Mysql No Comments »

Ok so i had a huge amount of trouble trying to upload a sqldump file (large sql file) into the mysql database with phpmyadmin. It kept timing out, even when I increased the timeout and upload file size larger in the php.ini file. So logged in using Putty and used the following SSH commands.

Show how many current open connections there are to mysql
mysqladmin processlist |wc -l

MySQL Dump
mysqldump -u username -ppassword dbname > file.sql

so if my username = alice, password = madhatter database name = wonderlanddb and I wanted to write to a file called sqlbackup.sql and the folder http://www.lenatsu.co.uk/databackup/ I would type:
mysqldump -u alice -pmadhatter wonderlanddb > /var/www/vhosts/lenatsu.co.uk/httpdocs/databackup/sqlbackup.sql

If a file ends in .zip (for example, file.zip) type:
unzip file.zip

If a file ends in .tar (e.g., file.tar) type:
tar -zxvf file.tar.gz

If a file ends in .gz (e.g. file.gz) type:
gzip -d file.gz

If a file ends in .tar.gz (e.g. file.tar.gz) type:
gzip -d file.tar.gz
and then
tar -xvf file.tar

Importing MySQL database
mysql -uusername -ppassword database_name < file.sql
So i would type:
mysql -u alice -pmadhatter wonderlanddb < /var/www/vhosts/lenatsu.co.uk/httpdocs/databackup/sqlbackup.sql

Right if it comes up with some rubbish like
/*!40101 mysql

then it ismost likely you have put “mysqldump” at the beginning of the command instead of “mysql”, last time it happened to me it took a couple of hair pulling hours to figure out why.

Rate This Post:

VI Commands:

Code Library, Linux Apache Server No Comments »

VI is like a text editor for linux command line, SSH, telnet etc not unlike notepad for windows.

VI Commands:

i                            insert mode, (ESC to exit insert mode) allows text to be entered on the screen
a                           Append to right mode
/word                  Move to the occurrence of “word”
n                           Locate the next occurance
w                          Advance to the next word
e                           Advance to the next end of a word
b                          Move to the previous word
3b                        Move backward 3 words
dd                        delete line
3dd                      delete 3 lines
D                          Delete remainder of a line
dw                        Delete word
x                          Delete character
o                          Open space for new line below the cursor line
O                         Open a line above the cursor
CTRL-w             Move back a word in append mode
u                          Undo last
U                         Undo all changes to current line
.                           In command mode, repeat the last text changing the command on the current line
:w newfilename        save the file to newfilename from the command mode
:wq                      save and quit
:q!                       quit without saving
r                          replace then typa a character ot be replaced with r then return to break up a line
J                          join 2 lines
s                          substitute (sentence) typed text over a character, ESC when done
cw                       change word
c                          change part of a line from the cursor to the end of the line
cc                        substitute new text for aline, ESC when done
h                          move the cursor back one space
H                          move the cursor to the highest line on the screen
L                          move the cursor to the lowest line on the screen
M                         position the cursor at the midpoint on the screen
G                          last line in the file
0 (zero)               Move the cursor to the beginning of the line it is on
view filename     Open a file for viewing only
set number         Turn on line numbers
set nonumber     Turn off line numbers

Options:

number
autoindent (ai)                 ctrl-d to move to the left
showmatch                       match brackets and parenthesis
tabstop=4
wrapmargine(wm)         when line is wrapped (80-value)
:2 copy 4                          Place a copy of line 2 after line 4.
:1,4                                    copy 7 (lines 1-4)
:n                                       Access the next file for editing

Rate This Post:
Entries RSS Comments RSS