apacheror

What if you need to migrate existing or new created Ruby on Rails web application to your PHP-Apache configured server?

If you are not using VPS or dedicated server and you have simple shared php web hosting – of course this article is not for you.

If you are in localhost, so everything is clear, you can use different webservers, different ports, you can damage your webserver, then reinstall it etc. But when you in production server, you can’t do such risks and you can’t play with webserver settings, ports.

So we need the way safer.

If you know what ssh, linux server are, let’s get started. Continue reading →

Screenshot from 2015-09-28 17:41:53

Creating localhost in Linux systems is very easy, you can install apache2, php, mysql separately and then integrate them or you can use ready packages for this(such as LAMP).

What if you have already one localhost under 127.0.0.1 IP and you want to create second one? In this case you don’t need to install additional software. You just need to dublicate some files and configure them. Let’s get started how to do it. Continue reading →

Screenshot from 2015-05-01 13:00:12

Today i installed webmin(visual server management tool) in my Azure Ubuntu server. After installation completed, i tried to login to webmin panel via https://IP:10000 , but no success. I did same installation a lot of times with another Linux servers and i surprised when i saw nosuccess in this last case. I tried some research with iptables, netstats, webmin conf file etc. But no result. At the end i have found that to create new access port you need to allow it via Azure Virtual Machine Dashboard.

So i did it, and now the port 10000 works.

This is how to do it:

1. Login to your Azure account ( http://azure.microsoft.com/en-us/)

2. Go to my account section (http://azure.microsoft.com/en-us/account/) Continue reading →

File Adobe Dreamweaver CSS-01

There are a lot of ways making web page to load faster. Google created dedicated project for this.(https://developers.google.com/speed/)

One of Google’s suggestion is this: Load css without render blocking. But those methods create another problem. Now i am telling which problem that is and how to solve it.

If your css code is small, Google advices to merge css code to your html, not include spearate css file. If your css code is large, Google advices to call it via Javascript, in this case css doesn’t cause page render. And web page opens too fast. Well, but what happens when javascript calls CSS file and CSS file is not fully loaded yet? Continue reading →

url

Let’s say that you have new server and you have copied all files from there, but you have forgotten to export mysql database. And old server no longer exists. I did this mistake 2-3 times when i migrated to a new computer.:) So, what to do? How to restore mysql tables from files? If you have full file backup, you should have mysql databases’ files, which have FRM extensions. Search and find them. In Linux they are in /var/lib/mysql. So 1. Copy ALL folders and files from /var/lib/mysql and paste them into /var/lib/mysql of new server. 2. It will not work immeditially. After pasting you should do mysql restart with folloing command in terminal: sudo service mysql restart That’s all.

Today i decided to install Python in Ubuntu OS and to use PHP and Python both together. If i hadn’t installed php and wanted to have python as only localhost in my OS, so it was easy, there are plenty of examples which show how to do it(for example). But if you have already installed php and you want to have python, then let’s go on. In this sample we will need two different ports if we want to do so. And i could easily install and test it. So i am sharing how i did it:

You have installed apache2-php in your Ubuntu(or other Linux based OS) and you want to install python for having python localhost. If python has not installed in your OS, do it. Let’s open Terminal:

sudo apt-get install python

Now you have python installed. Now we need apache mod for python. Let’s install it :

sudo apt-get install libapache2-mod-python

Then we must make some apache operations in terminal:

cd /etc/apache2/sites-available/ sudo gedit default

(default is the name of default apache conf file. )

You must see <virtualhost:*.80> …. </virtualhost> there.

Copy all block and paste it at the bottom. Then you will have two <virtualhost:*.80> …. </virtualhost> blockes. Then find in pasted block(second one) this:

Options Indexes FollowSymLinks MultiViews AllowOverride AuthConfig Order allow,deny allow from all

Add these lines to new line after “allow from all” :

AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On

Then go to first line of pasted part and edit

<virtualhost:*.80>

to

Listen 81 <virtualhost:*.81>

Save and close the file. Restart apache:

sudo /etc/init.d/apache2 restart

It is ready. Both PHP and Python work together in your OS. PHP has 80, Python has 81 port.

PHP – http://127.0.0.1 or http://127.0.0.1:80

Python – http://127.0.0.1:81

You can test python with simple test file which contains these 2 strings:

def index(req): return "Python works!";

In default apache virtualhost root localhost folder is /var/www. It is better to use different folders for Php and Python. For clear undersanding i am sharing my apache default conf file:

<virtualhost:*.80> ServerAdmin webmaster@localhost DocumentRoot /home/user/public_html/ Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </virtualhost> Listen 81 <virtualhost:*.81> ServerAdmin webmaster@localhost DocumentRoot /var/www/ Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride AuthConfig Order allow,deny allow from all AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On # Uncomment this directive is you want to see apache2′s # default start page (in /apache2-eh) when you go to / #RedirectMatch ^/$ /apache2-eh/ ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </virtualhost>

You can see from last sample that i use /home/user/public_html folder for PHP, and /var/www folder for Python.

That’s all. If any question, you can add it to comments.