| How do I optimize Apache to use less memory? | |
http://coded-words.tumblr.com/post/6936532107/configure-gmail-as-smtp-in-xampp-to-send-mail
So, after rummaging through the net for 2 whole days trying to look for good complete instructions to set up the mail server, I didn’t find. Eventually, I’d figured it out after piecing together random info from various numerous blogs and forums. Never have been this happy to finally successfully send a mail. So, I decided I’d put up the complete set of instructions to do so.
Below instructions are written for XAMPP1.7.4 (Working on Vista)
1. Open the PHP.ini file. (Most likely found in C:\xampp\php\php.ini or whichever drive you installed your XAMPP)
2. Search for the [mail function]
3. Change the settings to -
(Removing the ; enables the function.)
4. Save it and restart the Apache.
5. Open the sendmail folder (Found in the XAMPP folder thus C:\xampp\sendmail)
6. Chances are, the bundle probably comes with a weird combination of files and codes. So, to save all the hassle of troubleshooting afterwards, clear all the files in the folder.
7. Download a new version of the sendmail.zip from http://glob.com.au/sendmail/
8. Unzip the entire folder into the original sendmail folder - C:\xampp\sendmail
9. Open the sendmail.ini (C:\xampp\sendmail\sendmail.ini — found in the same folder)
10. Change the setting to the following — (I’ll post the entire file so no one gets confused from the cuts)
The bolded text are the ones that requires changes. Enter your google username and password where appropriate. I enabled the force_sender to be my mail because changing the php.ini is such a pain. You can alternatively choose to change the Mail from setting in the PHP.ini instead.
11. After this, all should be good. Run a mail script and send out the mail. It should work.
Hope this would relieve some distress from the whole SMTP setup. Have fun. :)
So, after rummaging through the net for 2 whole days trying to look for good complete instructions to set up the mail server, I didn’t find. Eventually, I’d figured it out after piecing together random info from various numerous blogs and forums. Never have been this happy to finally successfully send a mail. So, I decided I’d put up the complete set of instructions to do so.
Below instructions are written for XAMPP1.7.4 (Working on Vista)
1. Open the PHP.ini file. (Most likely found in C:\xampp\php\php.ini or whichever drive you installed your XAMPP)
2. Search for the [mail function]
3. Change the settings to -
[mail function]; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from =
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"(Removing the ; enables the function.)
4. Save it and restart the Apache.
5. Open the sendmail folder (Found in the XAMPP folder thus C:\xampp\sendmail)
6. Chances are, the bundle probably comes with a weird combination of files and codes. So, to save all the hassle of troubleshooting afterwards, clear all the files in the folder.
7. Download a new version of the sendmail.zip from http://glob.com.au/sendmail/
8. Unzip the entire folder into the original sendmail folder - C:\xampp\sendmail
9. Open the sendmail.ini (C:\xampp\sendmail\sendmail.ini — found in the same folder)
10. Change the setting to the following — (I’ll post the entire file so no one gets confused from the cuts)
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=465
; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL
smtp_ssl=auto
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
;default_domain=mydomain.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username=USERNAME@gmail.com
auth_password=PASSWORD
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.
;pop3_server=
;pop3_username=
;pop3_password=
; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content
force_sender=USERNAME@gmail.com
; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content
;force_recipient=
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required
;hostname=The bolded text are the ones that requires changes. Enter your google username and password where appropriate. I enabled the force_sender to be my mail because changing the php.ini is such a pain. You can alternatively choose to change the Mail from setting in the PHP.ini instead.
11. After this, all should be good. Run a mail script and send out the mail. It should work.
Hope this would relieve some distress from the whole SMTP setup. Have fun. :)
How to troubleshoot mail goes from console and not
working from web URL
Runtime Configuration
The
behaviour of these functions is affected by settings in php.ini.
Mail
configuration options
|
|||
Name
|
Default
|
Changeable
|
Changelog
|
"0"
|
PHP_INI_PERDIR
|
Available
since PHP 5.3.0.
|
|
NULL
|
PHP_INI_PERDIR
|
Available
since PHP 5.3.0.
|
|
"localhost"
|
PHP_INI_ALL
|
||
"25"
|
PHP_INI_ALL
|
Available
since PHP 4.3.0.
|
|
NULL
|
PHP_INI_ALL
|
||
"/usr/sbin/sendmail
-t -i"
|
PHP_INI_SYSTEM
|
||
getsebool
-a | grep mail
getsebool -a | grep
mail reports
[code]
allow_postfix_local_write_mail_spool --> on
httpd_can_sendmail --> off
[/code[
I fixed it with the following
setsebool
httpd_can_sendmail= on[code]
allow_postfix_local_write_mail_spool --> on
httpd_can_sendmail --> off
[/code[
I fixed it with the following
VNstat is a bandwidth monitoring tool that will let you monitor your bandwidth and provide daily, weekly and monthly tracking metrics.
To install and setup Vnstat, you will need to follow the steps in this article.
Log into your linux server and type the following command.wget http://humdi.net/vnstat/vnstat-1.10.tar.gz
Next to uncompress the file you will need to run the following command. tar -zxvf vnstat-1.10.tar.gz
Now that you have the file uncompressed, you will need to install Vnstat. To do this, you will need to navigate to the VNstat directory and run the following command.
make & make install
Now that it has been installed, you will first need to run "vnstat --iflist" on your server, so you know the name of your network adaptors. vnstat --iflist
You will now be presented with the any available adaptors on your server. Available interfaces lo eth0 sit0
Now that you know what adaptors you have on your server, you will need to tell VNstat to create a small database for that adapator. To do this, simply type /usr/bin/vnstat -u -i then the adaptor name. So for our example, we would run the following /usr/bin/vnstat -u -i eth0 If you have multiple adaptors, you will need to do this for each adaptor. However you do not have to if you only want to monitor specific adaptors.
Next, make sure that Vnstat restarts whenever you reboot your server. To do this, add the service to your server's "Chkconfig" list by running the following command.
chkconfig --add vnstat
chkconfig vnstat on
Now you can access Vnstat by logging into the server at anytime and typing "vnstat". Doing so will give you a realtime status of your bandwidth.
To install and setup Vnstat, you will need to follow the steps in this article.
Log into your linux server and type the following command.wget http://humdi.net/vnstat/vnstat-1.10.tar.gz
Next to uncompress the file you will need to run the following command. tar -zxvf vnstat-1.10.tar.gz
Now that you have the file uncompressed, you will need to install Vnstat. To do this, you will need to navigate to the VNstat directory and run the following command.
make & make install
Now that it has been installed, you will first need to run "vnstat --iflist" on your server, so you know the name of your network adaptors. vnstat --iflist
You will now be presented with the any available adaptors on your server. Available interfaces lo eth0 sit0
Now that you know what adaptors you have on your server, you will need to tell VNstat to create a small database for that adapator. To do this, simply type /usr/bin/vnstat -u -i then the adaptor name. So for our example, we would run the following /usr/bin/vnstat -u -i eth0 If you have multiple adaptors, you will need to do this for each adaptor. However you do not have to if you only want to monitor specific adaptors.
Next, make sure that Vnstat restarts whenever you reboot your server. To do this, add the service to your server's "Chkconfig" list by running the following command.
chkconfig --add vnstat
chkconfig vnstat on
Now you can access Vnstat by logging into the server at anytime and typing "vnstat". Doing so will give you a realtime status of your bandwidth.
http://perishablepress.com/stupid-htaccess-tricks/#sec6
Set the default language and character set ^
Here is an easy way to set the default language for pages served by your server (edit the language to suit your needs):# set the default languageDefaultLanguage en-USLikewise, here we are setting the default character set (edit to taste):
# set the default character setAddDefaultCharset UTF-8Declare specific/additional MIME types ^
# add various mime typesAddType application/x-shockwave-flash .swfAddType video/x-flv .flvAddType image/x-icon .icoSend character set and other headers without meta tags ^
# send the language tag and default character set# AddType 'text/html; charset=UTF-8' htmlAddDefaultCharset UTF-8DefaultLanguage en-USLimit server request methods to GET and PUT ^
# limit server request methods to GET and PUTOptions -ExecCGI -Indexes -AllRewriteEngine onRewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD) RewriteRule .* - [F]Selectively process files according to server request method ^
# process files according to server request methodScript PUT /cgi-bin/upload.cgiScript GET /cgi-bin/download.cgiExecute various file types through a cgi script ^
For those special occasions where certain file types need to be processed with some specific cgi script, let em know who sent ya:# execute all png files via png-script.cgiAction image/png /cgi-bin/png-script.cgiSecurity [ ^ ]
Prevent Access to .htaccess ^
Add the following code block to your htaccess file to add an extra layer of security. Any attempts to access the htaccess file will result in a 403 error message. Of course, your first layer of defense to protect htaccess files involves setting htaccess file permissions via CHMOD to 644:# secure htaccess filehtaccess>
order allow,deny
deny from all
Prevent Access to a Specific File ^
To restrict access to a specific file, add the following code block and edit the file name, “secretfile.jpg”, with the name of the file that you wish to protect:# prevent viewing of a specific fileorder allow,denydeny from allPrevent access to multiple file types ^
To restrict access to a variety of file types, add the following code block and edit the file types within parentheses to match the extensions of any files that you wish to protect:Order Allow,DenyDeny from allPrevent Unauthorized Directory Browsing ^
Prevent unauthorized directory browsing by instructing the server to serve a “xxx Forbidden – Authorization Required” message for any request to view a directory. For example, if your site is missing it’s default index page, everything within the root of your site will be accessible to all visitors. To prevent this, include the following htaccess rule:# disable directory browsingOptions All -IndexesConversely, to enable directory browsing, use the following directive:
# enable directory browsingOptions All +IndexesLikewise, this rule will prevent the server from listing directory contents:
# prevent folder listingIndexIgnore *
And, finally, the
IndexIgnore directive may be used to prevent the display of select file types:# prevent display of select file typesIndexIgnore *.wmv *.mp4 *.avi *.etcChange Default Index Page ^
This rule tells the server to search for and serve “business.html” as the default directory index. This rule must exist in the htaccess files of the root directory for which you wish to replace the default index file (e.g., “index.html”):# serve alternate default index pageDirectoryIndex business.htmlThis rule is similar, only in this case, the server will scan the root directory for the listed files and serve the first match it encounters. The list is read from left to right:
# serve first available alternate default index page from seriesDirectoryIndex filename.html index.cgi index.pl default.htmDisguise Script Extensions ^
To enhance security, disguise scripting languages by replacing actual script extensions with dummy extensions of your choosing. For example, to change the “.foo” extension to “.php”, add the following line to your htaccess file and rename all affected files accordingly:# serve foo files as php filesAddType application/x-httpd-php .foo# serve foo files as cgi filesAddType application/x-httpd-cgi .fooLimit Access to the Local Area Network (LAN) ^
# limit access to local area networkorder deny,allowdeny from allallow from 192.168.0.0/33Secure Directories by IP Address and/or Domain ^
In the following example, all IP addresses are allowed access except for 12.345.67.890 and domain.com:# allow all except those indicated hereorder allow,denyallow from alldeny from 12.345.67.890deny from .*domain\.com.*In the following example, all IP addresses are denied access except for 12.345.67.890 and domain.com:
# deny all except those indicated hereorder deny,allowdeny from allallow from 12.345.67.890allow from .*domain\.com.*This is how to block unwanted visitors based on the referring domain. You can also save bandwidth by blocking specific file types — such as
.jpg, .zip, .mp3, .mpg — from specific referring domains. Simply replace “scumbag” and “wormhole” with the offending domains of your choice:# block visitors referred from indicated domainsRewriteEngine onRewriteCond %{HTTP_REFERER} scumbag\.com [NC,OR]RewriteCond %{HTTP_REFERER} wormhole\.com [NC,OR]RewriteRule .* - [F]Prevent or allow domain access for a specified range of IP addresses ^
There are several effective ways to block a range of IP addresses via htaccess. This first method blocks an IP range specified by their CIDR (Classless Inter-Domain Routing) number. This method is useful for blocking mega-spammers such as RIPE, Optinet, and others. If, for example, you find yourself adding line after line of Apachedeny directives for addresses beginning with the same first few numbers, choose one of them and try a whois lookup.
Listed within the whois results will be the CIDR value representing
every IP address associated with that particular network. Thus, blocking
via CIDR is an effective way to eloquently prevent all IP instances of
the offender from accessing your site. Here is a generalized example for
blocking by CIDR (edit values to suit your needs):# block IP range by CIDR number order allow,denyallow from alldeny from 10.1.0.0/16deny from 80.0.0/8Likewise, to allow an IP range by CIDR number:
# allow IP range by CIDR numberorder deny,allowdeny from allallow from 10.1.0.0/16allow from 80.0.0/8Another effective way to block an entire range of IP addresses involves truncating digits until the desired range is represented. As an IP address is read from left to right, its value represents an increasingly specific address. For example, a fictitious IP address of 99.88.77.66 would designate some uniquely specific IP address. Now, if we remove the last two digits (66) from the address, it would represent any address beginning with the remaining digits. That is, 99.88.77 represents 99.88.77.1, 99.88.77.2, … 99.88.77.99, …etc. Likewise, if we then remove another pair of digits from the address, its range suddenly widens to represent every IP address 99.88.x.y, where x and y represent any valid set of IP address values (i.e., you would block 256*256 = 65,536 unique IP addresses). Following this logic, it is possible to block an entire range of IP addresses to varying degrees of specificity. Here are few generalized lines exemplifying proper htaccess syntax (edit values to suit your needs):
# block IP range by address truncationorder allow,denyallow from alldeny from 99.88.77.66deny from 99.88.77.*deny from 99.88.*.*deny from 99.*.*.*Likewise, to allow an IP range by address truncation:
# allow IP range by address truncationorder deny,allowdeny from allallow from 99.88.77.66allow from 99.88.77.*allow from 99.88.*.*allow from 99.*.*.*Block or allow multiple IP addresses on one line ^
Save a little space by blocking multiple IP addresses or ranges on one line. Here are few examples (edit values to suit your needs):# block two unique IP addressesdeny from 99.88.77.66 11.22.33.44# block three ranges of IP addressesdeny from 99.88 99.88.77 11.22.33Likewise, to allow multiple IP addresses or ranges on one line:
# allow two unique IP addressesallow from 99.88.77.66 11.22.33.44# allow three ranges of IP addressesallow from 99.88 99.88.77 11.22.33Miscellaneous rules for blocking and allowing IP addresses ^
Here are few miscellaneous rules for blocking various types of IP addresses. These rules may be adapted to allow the specified IP values by simply changing thedeny directive to allow. Check ’em out (edit values to suit your needs): # block a partial domain via network/netmask valuesdeny from 99.1.0.0/255.255.0.0# block a single domaindeny from 99.88.77.66# block domain.com but allow sub.domain.comorder deny,allowdeny from domain.comallow from sub.domain.com
To find
the largest 10 files (linux/bash):
# find
. -type f -print0 | xargs -0 du -s | sort -n | tail -10 | cut -f2 | xargs -I{}
du -sh {}
To find the largest 10 directories:
# find . -type d -print0 | xargs -0 du -s | sort -n | tail -10 |
cut -f2 | xargs -I{} du -sh {}
Only difference is
-type {d:f}.
No type for combined results.
For
a quick view:
# du | sort -n
Find directory size more than 500MB
# find . -type f -size +500000k -exec ls -lh {} \; |
awk '{ print $9 ": " $5 }'
Find
OUT large hists form IP
#
awk '{print $1};' /var/log/httpd/access_log | sort | uniq -c | sort -rn | head
Find
out directory files count
# ls -l | awk '!/^d/{print }' | wc -l
# ls -la |wc -l
# find . |wc –l
Find
file which older than 30 days or modify
# find
. -mtime +30
Delete old files older than
x days with subdirectories
# find . -mtime +10 -exec rm {} \;
This will
show you how to find the ten biggest files / folders on your linux system
# du -a / |
sort -n -r | head -n 10
You can
use the command to find the biggest files in a specific location like this
# du -a
/var/www | sort -n -r | head -n 10
And you
can return more than ten results like this
# du -a
/var/www | sort -n -r | head -n 25
Large Files
Find files larger than 10MB in the current directory downwards…find . -size +10000000c -ls |
find . -size +100000000c -ls |
Old Files
Find files last modified over 30days ago…find . -type f -mtime 30 -ls |
find . -type f -mtime 365 -ls |
find . -type f -atime 30 -ls |
find . -type f -atime 365 -ls |
Find Recently Updated Files
There have been instances where a runaway process is seemingly using up any and all space left on a partition. Finding the culprit file is always useful.If the file is being updated at the current time then we can use find to find files modified in the last day…
find . -type f -mtime -1 -ls |
touch testfilefind . -type f -newer testfile -ls |
Finding tar Files
A clean up of redundant tar (backup) files, after completing a piece of work say, is sometimes forgotten. Conversely, if tar files are needed, they can be identified and duly compressed (using compress or gzip) if not already done so, to help save space. Either way, the following lists all tar files for review.find . -type f -name "*.tar" -lsfind . -type f -name "*.tar.Z" -ls |
Large Directories
List, in order, the largest sub-directories (units are in Kb)…du -sk * | sort -n |
Removing Files using Find
The above find commands can be edited to remove the files found rather than list them. The “-ls” switch can be changed for “-exec rm {}\;”=.e.g.
find . -type f -mtime 365 -exec rm {} \;
Subscribe to:
Comments (Atom)