Web-server on Ubuntu (PHP + MySQL + Apache) in 2 commands

Fast and easy install (PHP + MySQL + Apache) LAMP on Ubuntu

Step 1: install tasksel

sudo apt-get install tasksel

Step 2: Run install PHP, MySQL & Apache as LAMP server

sudo tasksel install lamp-server

Completed! Now you have installed PHP, MySQL, and Apache on your Ubuntu

Additional: Create site area
Continue reading Web-server on Ubuntu (PHP + MySQL + Apache) in 2 commands

If you got 500 (Internal Server Error) PHP/Nginx/Apache – Where you can found logs/reason?

Oh, noooo. You got most popular developer error 🙂
Firstly, No despair – say “Yes, I CAN”, and concentrate on possible errors.

1 step: Double check your PHP/Python/ETC code.
find_errors_ercule
Show all errors (how to show all errors/warnings/nootices in php)
Also, you can do “fast debug” in main parts of you code (Sure, use die() command but very carefully)

 

2 step: Check server/Apache&PHP settings
domino_server_settings_phpFirstly check .htaccess file on strange symbols or sentences.
Also, if you using POST method with uploading files then check php settings in php.ini (max_post_size, max_executing_time…)

 

3 step: Check error logs (Ubuntu/Linux)
find_errors_in_logs
Standard Apache logs dev finiding here:

/var/log/apache2/...

nginx logs here:

/var/log/nginx/...

Also, some popular frameworks logs folders:
Continue reading If you got 500 (Internal Server Error) PHP/Nginx/Apache – Where you can found logs/reason?

How to run Python Scripts ( *.py files) on Apache2 (configuring unix apache2 servers)

Preparing (install apache2, python):
Installation Apache2:

sudo apt-get install apache2

Installation Python(choose one):

sudo apt-get install python
sudo apt-get install python2.7
sudo apt-get install python3

First step: enabling CGI processing in your apache (automatically enable mod_cgid).

sudo a2enmod cgi

Second step: Allow run CGI scripts in your directory.
You can try allow by .htaccess in your “python” web folder

Options +ExecCGI
AddHandler cgi-script .py

or you can allow .py files to be executed as scripts in a particular folder you would use config in apache conf file:

    <Directory /srv/www/mysite/public_html/python_folder>
        Options +ExecCGI
        AddHandler cgi-script .py
    </Directory>

Finish step:
Continue reading How to run Python Scripts ( *.py files) on Apache2 (configuring unix apache2 servers)

XAMPP: Change localhost to custom domain name

For windows developers [default disk: C]:
Example: www.mysite.tst instead of localhost/mysite.
Step 1: Go to C:\Windows\System32\drivers\etc and edit “as Administrator” => hosts file.
Add in end of file:

127.0.0.1	mysite.tst

Save and close.

Step 2: Go to C:\xampp\apache\conf\extra and edit httpd-vhosts.conf file.
Add in end of file:

<VirtualHost *:80>
    ServerName www.mysite.tst
    ServerAlias mysite.tst
    DocumentRoot c:/xampp/htdocs/mysite
</VirtualHost>

Save and close.

Final step…
Continue reading XAMPP: Change localhost to custom domain name

How to set right page encoding using PHP (UTF-8 HTTP header)?

Quite frequently, many are faced with the problem: incorrect definition of the browser page coding.
The easy way to fix it – set the right page encoding by PHP.
Example (we use the encoding utf-8) ↓

<?php
header('Content-Type: text/html; charset=utf-8');
/*....*/
?>

Additionally, you can specify the encoding using HTML
Continue reading How to set right page encoding using PHP (UTF-8 HTTP header)?