How to create files and directorys in var/www? [duplicate]
In a terminal use the next commands:
cd = Change Directory
cd /var/www
mkdir = Make Directory, this command requires elevated privileges, so run it with sudo or gksudo
sudo mkdir foldername
(where foldername is the name of the folder that you wish to create).
You can create subfolders from within /var/www
without changing to the desired destination by using:
sudo mkdir foldername/subfolder
cp = Copy one or more files to another destination
cp PATHTOSOURCE/file.php PATHTODESTINATION
This can be used for any kind of file.
Note: If you wish to use a GUI for these tasks, you can use Nautilus with elevated privileges, simply hit Alt+F2 and write gksudo nautilus
, then Enter after which you will see Nautilus File Browser, press Control+L and write /var/www
and you can copy/paste or drag/drop anything you wish with ease.
For a comprehensive list of the commands, visit: http://ss64.com/bash/
Good luck!
By default files under /var/www are protected. To create content under /var/www you must have root privilege.
To gain root privilege use
sudo su
Check Apache
To make sure your apache is running fine open your browser and open http :// localhost/ . If you get a message saying "It works" Your lamp installation is successful.
Test php
Using terminal create a test php file
echo "<?php phpinfo(); ?>" | sudo tee /var/www/test.php
restart apache sudo /etc/init.d/apache2 restart
Now open http://localhost/test.php in your browser. You should get the php related configurations as output.
To create directory
mkdir
eg: mkdir my_website
To copy files
cp source destination
eg: cp /tmp/test.php /var/www/my_website/
To copy whole directory
cp -r source_dir dest_dir
eg cp -r /tmp/mywebsite_content /var/www/my_website