How to create php files in /var/www folder?
58,387
Open /var/www/
cd /var/www/
Create the file
sudo touch hello.php
Open the file
sudo vi hello.php
Enter write mode (we were in command mode initially) by pressing a
(note that vi
is case sensitive)
After that, press Esc
(to change to command mode) and type :wq
. Check if everything is fine with cat hello.php
.
However, it's probably a better idea to use editors such as vim
or nano
as work with them is a lot simpler than that.
Related videos on Youtube
Author by
Sri
Updated on September 18, 2022Comments
-
Sri over 1 year
I am new to Ubuntu(Linux) and I am trying to create a php file in
/var/www
, file namehello.php
. I am typingvi hello.php
and then I write my code<?php......?>
, however, when I am trying to save the file by:wq
, I get an error and no file by the name of Hello.php is created..-
david6 over 9 yearsTry using vim instead, unless you are completely unable to load/install any software.
sudo apt-get install vim build-essential
-
smali over 9 yearswhat error you are getting?
-
Melebius about 4 years@david6
vi
is a synonym ofvim
in Ubuntu.
-
-
Sergiy Kolodyazhnyy over 9 yearsIsn't vim comes in the default install of Ubuntu, and vi is just a sim-link to it?
-
karel over 9 yearsIn Ubuntu 14.04, vim comes in the default installation of Ubuntu server, but vim doesn't come in the default installation of Ubuntu desktop. Source: releases.ubuntu.com/14.04
-
Vinit Kadkol about 4 yearsGo to the folder root$: cd /var/www/html create file sudo touch hello.php check your file in the list by typing "ls" root$:/var/www/html$ ls edit the file and save root:/var/www/html$ sudo nano hello.php