Tag: apache

How to test PHP installation

To test a successful php installation. We can check the PHP version in your machine or test the entire PHP setup using following

open a file in which your web directory name it anything like php_test.php and write the following content.

?php
phpinfo();
?>

Save the file and open the file in your browser like localhost/php_test.php.

Then you will notice that if php is installed the following image will be displayed.

PHP successful installation screenshot

There is a video tutorial that explains the same as above.

Setting Reverse Proxy in Apache Ubuntu

Suppose we have a web app running on a port. For example nodejs runs server on a port. For accepting incoming connections on this port without actually exposing the port number is what we look for.

To solve this we can add few lines in our apache configuration to tell our web server to accept connections on a port.

Lets assume we are trying to access this url

http://127.0.0.1:8080/mybankapp

Open the file /etc/apache2/sites-available/000-default.conf using any editor and paste the below lines. You may take a backup of the above file before doing so.

<VirtualHost *:80>
    ProxyPreserveHost On

    ProxyPass /mybankapp http://127.0.0.1:8080/mybankapp
    ProxyPassReverse /mybankapp http://127.0.0.1:8080/mybankapp
</VirtualHost>

Before we restart apache we may enable some modules.

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests

After we execute above command now we may restart apache.

sudo systemctl restart apache2

Now we can access our web app without the port number.

Handling error “You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit.”

Handling error “You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit.”Usually, we come across such errors when we try to import a large file in to MySQL through phpmyadmin. This is because there is a pre-defined file limit in PHP for file upload which is 2MB.You may change the file upload limit as per your requirement by changing php configuration following the below steps :1. Navigate to apache2 directory and open php.ini file using vi or vim editor.

root@user-B85M-D3H:~# vim /etc/php5/apache2/php.ini 

2. Change the values of the following lines to as per your requirement.(I am changing the limit to 120 MB here)

&nbsp;upload_max_filesize 120M //file size
&nbsp;post_max_size 120M
&nbsp;max_execution_time 200
&nbsp;max_input_time 200

3. Please ensure that the max_execution_time, max_input_time should always be greater than upload_max_filesize and post_max_size.

4. Once you make the changes, save the file and restart the apache server using the command :

service apache2 restart 

Hope this helps. Happy coding!