How to start with PHP on Ubuntu

I am new to PHP. I have successfully installed PHP on Ubuntu, now I want to start my first program. I am using gPHPEdit as an IDE. Where should I save the .php files that I create? And how to run / test them?

+3
source share
4 answers

You should pick up a book or start following good textbooks online.
If you just use php scripts, you can save them anywhere and run php on the terminal using the php command line interpreter.
If you are trying to write web scripts (and I think so), you need to install and configure a web server (usually apache) and save your scripts in the server root document (usually / var / www). In addition, I highly recommend that you read a little about servers and HTTP and find out how it all works internally before learning to create sites in php.

+1
source

, LAMP. sudo tasksel , enter, * amp install, - . phpmyadmin: sudo apt-get install phpmyadmin. /var/www/, http://localhost. Eclipse PDT Netbeans PHP.

+4

var/www/html, php- . Ubuntu 14.04. , .

  • sudo su .
  • sudo subl /etc/apache2/sites-available/000-default.conf , . , , , sudo nano /etc/apache2/sites-available/000-default.conf.
  • DocumentRoot /var/www/html /home/user/yoursubdir
  • .
  • sudo subl /etc/apache2/apache2.conf , .
  • <Directory /home/user/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory> 
    
  • .

  • sudo service apache2 restart
  • Go to your browser, enter the URL of your script for example 127.0.1.1/directory/document.php.

Hope this helps.

+1
source

delete index.html file with /var/www/

$ sudo rm index.html

create a new php file there:

$ sudo gedit /var/www/index.php

write in it:

<?php
print_r(phpinfo());
?>

Restart the Apache2 server:

$ sudo service apache2 restart

OR

$ sudo /etc/init.d/apace2 restart

and point to your localhost and /index.php

if an error occurs: http://www.allaboutlinux.eu/how-to-run-php-on-ubuntu/

+1
source

Source: https://habr.com/ru/post/1796672/


All Articles