Upgrade XAMPP in Windows

I had to write this article cause I couldn’t find any complete solution to help people out with updating XAMPP in Windows. Well, finally here is a easy to understand, step by step guide to upgrade XAMPP that actually works. Kudos!

SOME MAJOR CHANGES!

If you are updating XAMPP after a long time like me than be ready for some major changes. XAMPP no longer comes with the MySQL server. Since XAMPP 5.5.30 and 5.6.14, XAMPP ships MariaDB instead of MySQL. So copy pasting the mysql data files from old to new xampp won’t work anymore!

THE CHALLENGES!

While updating XAMPP we basically face 2 challenges

  1. Moving all the site files. This portion is easy just a simple copy paste will do the trick.
  2. Moving all the databases to the new server. And most often this is the main issue why we don’t update XAMPP very often. Cause backing up all the databases one by one and then importing them to new server is really a long boring work.

THE COMPLETE SOLUTION:

Follow the following steps and you will be there in no time!

BACKUP OLD DATA!

Lets backup all the databases first

  1. Open XAMPP Control Panel as an Administrator
  2. Click on the Shell option
  3. run the following command mysqldump -u root -p --all-databases > all-db-dump.sql
  4. If you have different user for databases then change the value ‘root’ with username. If you don’t have any password just press enter. Otherwise provide the password.
  5. This will create a SQL file named “all-db-dump.sql” that contains all the databases in MySQL server. You will find this file in xampp folder.
  6. Now stop both Apachee and MySQL servers and quit the xampp control panel. Close the command prompt too.
  7. Now rename your ‘xampp’ folder to ‘xampp-old’. This way if anything goes wrong you will be able to get back to the old version very easily.

LETS INSTALL THE NEW ONE!

  1. Download the latest version of XAMPP.
  2. Install it in the same drive where your old xampp currently is.
  3. Now go to xampp folder and run the xampp control panel as Administrator.
  4. Start both Apachee and MySQL server and check whether they are working properly or not, also check PhpMyAdmin page.
  5. Now Copy the htdocs folder from ‘xampp-old’ folder to ‘xampp’ folder.
  6. Go to xampp\php\php.ini
  7. Now configure the php.ini file and increase the value for the following options upload_max_filesize,memory_limit, post_max_size .
  8. post_max_size and memory_limit need to be larger than upload_max_filesize. Make them high enough so big files can work on the server.
  9. Go to ‘xampp\phpMyAdmin\libraries\config.default.php’
  10. Look for $cfg[‘ExecTimeLimit’] = 600;
  11. Change the value 600 to a higher value may be 6000.
  12. Now restart both Apache and MySQL server.
  13. Now go to phpMyAdmin
  14. Go to Import tab
  15. Import ‘all-db-dump.sql’ file through the import option directly to server.
  16. Based on how many databases you have it will take some time.
  17. If you have followed all the steps correctly you will get a success message “ Import has been successfully finished”.
  18. Go ahead and check whether your site and databases are working properly or not.
  19. If everything is working fine than you can delete the xampp-old file.

If you have followed my instructions then you should have a functioning XAMPP with no issues.

 

SOURCE: https://medium.com/@asif.rocks/how-to-upgrade-xampp-in-windows-the-easy-way-93031fc923ce

Parse apache vhosts file

So, I wanted to parse the apache config file so I could get the ServerName and the DocumentRoot of each VirtualHost.

awk '/^<VirtualHost*/,/^<\/VirtualHost>/{if(/^<\/VirtualHost>/)p=1;if(/ServerName|DocumentRoot|## User/)out = out (out?OFS:"") (/User/?$3:$2)}p{print out;p=0;out=""}' vhosts.conf

The command will output the info in the format:

ServerName DocumentRoot

or opposite depending on the order in which they appear on the VirtualHost

 

Note: You should exclude those VirtualHosts which are only redirects

Change sendmail queue

To actually change it, modify the /etc/sysconfig/sendmail file. It’ll look something like this:

DAEMON=yes
QUEUE=1h

Change the QUEUE unit to suit your preferences.

QUEUE=5m

Forcing queue send on individual email message

You can flush the message with:

sendmail -qIyourqueueID -oTnow

The “I” flag to the -q flag specifies which queue ID to use. The -oTnow flag sets the queue timeout to “now”. Note sendmail will still try to deliver the message once when you do this.

Permissões para escrever numa pasta no IIS 7.5

Giving write permissions to all IIS_USRS group is a bad idea from the security point of view. You dont need to do that and you can go with giving permissions only to system user running the application pool.

If you are using IIS7 (and I guess you do) do the following.

  1. Open IIS7
  2. Select Website for which you need to modify permissions
  3. Go to Basic Settings and see which application pool you’re using.
  4. Go to Application pools and find application pool from #3
  5. Find system account used for running this application pool (Identity column)
  6. Navigate to your storage folder in IIS, select it and click on Edit Permissions (under Actions sub menu on the right)
  7. Open security tab and add needed permissions only for user you identified in #3

 

Note #1: if you see ApplicationPoolIdentity in #3 you need to reference this system user like this IIS AppPool\{application_pool_name} . For example IIS AppPool\DefaultAppPool

Note #2: when adding this user make sure to set correct locations in the Select Users or Groups dialog. This needs to be set to local machine because this is local account.

 

SOURCE: http://stackoverflow.com/a/14654062

Vulnerable service: Netbios

Go into your firewall file /etc/sysconfig/iptables.

If you use Active Directory and want to enable that function ONLY in Samba use.

-A RH-Firewall-1-INPUT -s 192.168.10.0/24 -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.10.0/24 -m state --state NEW -m udp -p udp --dport 445 -j ACCEPT

Don’t be scared of the syntax. I’m not going to cover firewalls but understand the basics.

-s (ip address) limits to the Class C ip addresses of your installation. Of course you need to modify to your own network and this makes is far more secure than giving the entire world access to your network.

--state NEW [basically means a new rule.]

-p [the port you want to open up which is either tcp or udp. I’ve done the hard work for you so you don’t have to figure out which type to open up]

dport 445 [This is the port number. Again for AD we use port 445.

Now, if your Samba setup demands the old netbios calls:

-A RH-Firewall-1-INPUT -s 192.168.10.0/24 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.10.0/24 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A RH-Firewall-1-INPUT -s 192.168.10.0/24 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

Be sure to watch out for case issues and don’t make a mistake on tcp or udp otherwise samba won’t function properly. This has to be right — as I’ve found out myself with a couple of typos!

Now restart the firewall. There are two ways of restarting a service on CentOS

  1. service iptables restart
  2. /etc/init.d/iptables restart

Either one works. You can also just restart the server if you want to as well.

note: You can use Redhat’s system tool for editing the firewall, but it is not recommend. It won’t add the -s parameter and will open up all the samba ports 137 – 139 and 445 which is not a recommended scenario.

SOURCE: https://wiki.centos.org/HowTos/SetUpSamba

Delete spam messages from sendmail queue

One website was hacked and was being used to send spam emails. Sendmail was making the server to halt because of high load!

After cleaning up the site and installing a Malware detector (maldet) I had to delete the messages from the sendmail queue so the server didnt kept getting a high load.

I created this simple bash script to work it out. Obviously you need to uncomment the rm command to make it work.

 

#!/bin/bash

ls -1 | while read fn
do
 if grep -E -q "Wrestling|Asian|pharma|sucking|masturbates|bondage|medic|experience|antidote|poison|presence|jerking|blowjob|boobies|mature|teen|loaded|virgin|noblefox.net|dong|hungers|brainwashing|heartfelt|slave|russian|mistress" "$fn"
 then
   if [[ "$fn" != "remove.sh" ]]
   then
     echo "would delete $fn"
     # rm $fn
   fi
 fi
done

Visual Studio Code: hide .js and .js.map files

In File > Preferences > User Settings hide .js files when there is a matching .ts file.

{
 "files.exclude": {
 "**/.git": true,
 "**/.svn": true,
 "**/.hg": true,
 "**/.DS_Store": true,
 "**/*.js": {"when": "$(basename).ts"},
 "**/*.map": {"when": "$(basename).map"}
 }
}

Instalar módulos PECL/PEAR PHP no CentOS

The default RHEL 5.2 installation does not come with xdebug as part of any of the php RPMs. A quick look around the Net also provided no real RPM candidates that I could use on this system so I had to fall back to using the package management tools (pecl and pear) provided by php.

$ sudo pecl install xdebug
downloading xdebug-2.0.3.tgz ...
Starting to download xdebug-2.0.3.tgz (286,325 bytes)
...........................................................done: 286,325 bytes
66 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
/usr/bin/phpize: /tmp/pear/download/xdebug-2.0.3/build/shtool: /bin/sh: bad interpreter: Permission denied
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

ERROR: `phpize' failed

Yep, loving it already!

Why on earth am I not able to invoke /bin/sh (as can be seen by the ‘/bin/sh: bad interpreter: Permission denied’ error above)? Let’s see if root can actually run the shell interpreter:

$ sudo /bin/sh
sh-3.2# exit

OK, everything looks good. Why is it breaking when we’re trying to run the interpreter from /tmp/pear/download/xdebug-2.0.3/build/shtool?

Back to basics

Perhaps this has something to do with where we’re trying to run it from and the user we’re doing the installation as (root) seems to be capable of running the interpreter but not from the shtool script for some reason.

$ ls -ld /tmp/
drwxrwxrwt 17 root root 4096 Jun 18 07:41 /tmp/

Obviously _not_ a permissions issue.

$ grep tmp /etc/fstab
/dev/sda2     /tmp    ext3    defaults,nosuid,nodev,noexec    1 2

Ah, there you are! /tmp is mounted with a ‘noexec’ flag so that’s what’s causing the execution to fail when we try to install xdebug via pecl. No problem, I’ll just set pecl to use /var/tmp instead … oh, wait, on RHEL systems /var/tmp is just a symlink to /tmp.

*sigh*

Hand me half a brick

Time to work around the issue. Let’s go find those directories pear expects to be somehow related to /tmp or /var/tmp:

$ pear config-show | grep tmp
PEAR Installer download        download_dir     /tmp/pear/download
PEAR Installer temp directory  temp_dir         /var/tmp
$ pear config-set download_dir /root/tmp/pear/download
$ pear config-set temp_dir /root/tmp

I updated these to temporarily point elsewhere:

$ pecl config-show | grep tmp
PEAR Installer download        download_dir     /root/tmp/pear/download
PEAR Installer temp directory  temp_dir         /root/tmp

$ sudo mkdir -p /root/tmp/pear/download

Source: http://blog.ntrippy.net/2008/06/installing-peclpear-php-modules-on-rhel.html

Atualizar ICU para o php-intl no CentOS

I chose to install the latest version for CentOS 5 available on http://site.icu-project.org.

make sure we have the developer packages needed for procedure

# yum -y install php-devel php-pear

download and unpackage tar which code for relevant ICU lib version

# mkdir src
# cd src/
# wget http://download.icu-project.org/files/icu4c/58.1/icu4c-58_1-src.tgz
# tar zxf icu4c-58_1-src.tgz

build and install the library into /opt/icu4c-58_1

# cd icu/source/
# ./configure --prefix /opt/icu4c-58_1 && make && make install

build and install the php-intl version
enter /opt/icu4c-58_1 at prompt for ICU library location

# pecl install intl
# ldconfig

add an ini file wity contents: extension=intl.so

# vi /etc/php.d/intl.ini

you can now check to see if it’s loaded

# php -i | grep intl

restart the apache web server and you’re good to go

# service httpd restart