Couple days ago, I ran into this error on CentOS 5.2. To my understanding this error can occur on all flavors of linux.
This totally caught me by surprise as I had never seen this before. I had just finished installing awstats and wanted to run an update for the first time. The logs were gathered from 6 webservers and each webserver had about 225 logs.
The awstats log merging script tried to open these log files (225×6 = 1,350 logs) and merge them to read the data but it kept crashing. The reason it kept crashing was because the limit for the maximum number of files that you are allowed to open in a shell was set to 1024.
To check what your limits are just type in the following command:
ulimit -a
To change the limit for the number of files you are allowed to open, change the “open files” limit. To do so, type in the following command:
ulimit -n3000
This will set the limit to 3000 files. You can set it to whatever number you need to.
After changing my “open files” limit, I was able to run my initial awstats update without any issues.
Follow the steps below if you have forgotten your mysql root password and wish to reset it.
1. Create a text file with the following information in it.
UPDATE mysql.user SET Password=PASSWORD(’NEW_PASSWORD’) WHERE User=’root’;
FLUSH PRIVILEGES;
Replace “NEW_PASSWORD” with your desired mysql password. Save the file to /etc/mysql-pass-reset
2. Stop MySQL
/etc/init.d/mysqld stop
3. Start mysqld_safe with the –init-file option like so:
mysqld_safe –init-file=/etc/mysql-pass-reset &
This will start mysql and execute the query in the text file you created.
4. Now stop and start mysql back up normally without the –init-file option.
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
Don’t forget to delete the “mysql-pass-reset” file when you are done!
rm /etc/mysql-pass-reset
Here are the quick an easy steps on how to install TOS in Linux (Debian Distro).
First you will need to setup Java on your computer so lets go ahead and do that. Open up the console and login as super user.
su
Now that we have full privileges, lets edit the sources.list file so that we can fetch the much needed java packages.
pico /etc/apt/sources.list
This will bring up your sources.list file in the editor. You should see something that looks like this:
deb http://debian.lcs.mit.edu/debian etch main
deb-src http://debian.lcs.mit.edu/debian etch main
Add the words “contrib non-free” at the end of both lines so it looks like the following:
deb http://debian.lcs.mit.edu/debian etch main contrib non-free
deb-src http://debian.lcs.mit.edu/debian etch main contrib non-free
Now hit “Ctrl + O” to write the changes to the file. Then hit enter to accept the changes. Now hit “Ctrl + X” to exit the editor. That was the hard part :). Lets update our package listing and download the java packages by running the following commands:
apt-get update
apt-get install sun-java5-jre sun-java5-jdk
Follow the onscreeen instructions to complete the installation of the java packages. Its pretty much gonna ask you to agree to the licenses. After you are done you can close the console window.
Now log in to your TOS account and download their software for Linux. Save it to your desktop. Once the download is complete you should have a shell script file sitting on your desktop. The extension of the file should be .sh. Go ahead and open your console again.
Type in the following command to change your current working directory to your desktop directory:
cd Desktop
Now lets make the installation script executable.
chmod +x thinkorswim_installer.sh
We are ready to install the software now. Just type in the following command.
./thinkorswim_installer.sh
If you get an xserver error just run the command again with the “-c” argument like this:
./thinkorswim_installer.sh -c
Now just follow the on screen instructions. Let it install in the default directory “/usr/local/thinkorswim”. Once that is done installing we need to change the permissions on the installation folder so that it doesn’t stall on the update page. To do this we need super user privileges.
su
Now lets change the permissions on the entire thinkorswim folder recursively.
chmod 777 /usr/local/thinkorswim -R
Thats it, you are all set now. You can run the program by navigating to /usr/local/thinkorswim and clicking on the thinkorswim executable file.
You can also create a shortcut in your start menu. In KDE just right click on the kmenu and go to edit. Add a new menu item and enter the following in the path field:
/usr/local/thinkorswim/thinkorswim.sh
Thats it!
Centering items using CSS is actually very easy. If you want to center a picture horizontally then just use the following code in your CSS file.
IMG.centered {
display: block;
margin-left: auto;
margin-right: auto;
}
What the above CSS code does is center an image between the left and right margins automatically. Whenever you insert an image just make sure to call the “centered” class, for example:
<img class=”centered” src=”/images/someimage.jpg” alt=”some text” />
If you want to center something vertically then you would need to use a container. For example:
DIV.container {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: fixed;
display: table;
}
P {
display: table-cell;
vertical-align: middle;
}
Now that you have the CSS part done lets look at the HTML part.
<div class=”container”>
<p>This text is vertically centered</p>
</div>
Now lets combine both of the techniques together to have an image that is horizontally and vertically centered in a browser window.
CSS Code:
DIV.container {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: fixed;
display: table;
}
P {
display: table-cell;
vertical-align: middle;
}
HTML Code:
<div class=”container”>
<p>The image below is vertically and horizontally centered.<br />
<img class=”centered” src=”images/someimage.jpg” alt=”some text” /></p>
</div>
Thats It!
It is always a good idea to pick one format for your website URL and stick with it. If you want to make sure all your URLs have a “www” in front of them then paste the following code at the top of your “.htaccess” file.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\\(/)([^w][^w][^w][^.].*/(www\.)¦.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www. ^(/)?(/)?([^w][^w][^w][^.].*/(www\.))$ [NC]
RewriteRule ^ http://%4%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]
The above code uses the apache mod_rewrite module to rewrite your URL. It also makes sure that there is a trailing slash at the end of your URL. This website is using the above code to make sure all URLs load with a “www” and have the appropriate trailing slashes.