Raspberry pi web server - raspberry-pi3

I've been trying to set up my own web server with the raspberry pi3 b+ and it was going good so far i could made a ddns and access it from any other wifi or anything, the only problem was that i couldn't change the default "Debian apache" site.
I googled a lot about it and everybody said that all i have to do is change the root directory /var/www/to my directory but i just couldn't save the files, as it asked me if I wanna overwrite it - I pressed yes but it told me that I don't have permission for that I also couldn't overwrite the index.html file that was in the default folder. Is there anything I can do about it?

I had the same problem while doing this myself. You need to open terminal from the Raspberry Pi, or SSH. You need to change the folder type to 755, which allows the user to read,write,execute. Make sure that the directory you do this to is the /var/www/html folder.
All you need to do is type:
chmod -R 755 (dir)
dir = directory of the file.
If you'd like to change a file, such as the default index.html file in there, use 744 instead of 755.
After this, if you want to start the server, just type in
sudo service apache2 start
Here's a link for how to install the apache2 package.
https://pimylifeup.com/raspberry-pi-web-server/

Related

Vagrant synced folder link to Apache /var/www/ in Ubuntu VM

I'm not sure how to phrase the title; hopefully, it made sense. I am learning about Vagrant and just found out about synced folders. I am doing web development and want to edit/create my files and folders on my local machine instead of Ubuntu 14.04 (on Vagrant).
I store my files in my /vagrant/ folder, which end up appearing on both machines. This is perfect. I want these folders/files to be automatically moved to /var/www/ as soon as a file or folder is changed in the synced folder.
For example:
Make folder on Windows 10 called test inside the synced folder. Put index.html inside test.
The folder and file are uploaded to the Ubuntu machine.
Inside of /var/www/ in the Ubuntu machine, there should be a copy of the test folder along with all the files inside of it.
The test folder inside /var/www/ updates if any changes are made in the synced folder /vagrant/.
I was looking into the ln command but I keep getting an error saying "hard links not allowed". I was trying like this on Ubuntu:
cd /vagrant
ln test /var/www/
Should I approach this differently? How can I accomplish what I want to do? Thanks in advance!
You can do sharing folder using vagrant, it is called synced folder in Vagrant terminology
If you want to sync the guest /var/www you can add the following in your Vagrantfile
config.vm.synced_folder "www/", "/var/www"
so if you create the www/ folder within your local/host project folder, any files that you will save under this www folder will automatically be synchronized with the /var/www folder of your ubuntu machine
vagrant/virtualbox do not really limit you in the number of sync folder so you should adopt that rather than using one and work with symlink.
Another way of syncing your folder is to create a soft link in linux. Just type this into your command line:
rm -rf /var/www
ln -fs /vagrant /var/www
This will remove the /var/www folder and create a soft link so that whoever tries to go to /var/www will be automatically be redirected to your synced folder which in this case is /vagrant but you can change that to something different.
you can also create a shell script for this so that every time you create a virtual instance, it can automatically do this for you instead of you having to manually do it every time.
Here is a link to how to make the vagrant file run a shell script when you vagrant up:
https://www.vagrantup.com/docs/getting-started/provisioning.html

Can't see images in localhost

I'm starting to develop a site in ubuntu 14.04. I'm using apache2, so I placed my files under /var/www/html/ folder. Everything was working fine, but I had to restart my current work so I copied the entire project folder from another path, like this
$ sudo cp ~/path/to/folder /var/www/html/
And now I can't see my images, a simple imgtag. I just see this.
When I look for the file, I can see that I'm having an error 403 forbidden. I saw some suggestion to add the option Require all granted but that option is already set in my apache. I suspect that is because the new folder is a copy from a folder without root permissions, so I tried chmod but that also didn't work so I'm completly lost now.
So, how can I see my images from localhost? and most important is why this happen suddenly?

public_html folder invisible

I have a website which I copied to this location. The public_html folder was also uploaded with the other folders but it is not showing up. Please guide me. Thanks.
As you are using DreamHost web hosting you wont have any control over ssh and chmod , chown commands. I think dreamhost wont use cPanel for shared hosting, they have their own control panel, so there is nothing you can do, Ask dreamHost support to reinitialize your public_html directory. Surely they will do that. I searched on dreamhost forum and found these link-
https://discussion.dreamhost.com/thread-13646-post-13647.html#pid13647
https://discussion.dreamhost.com/thread-128630.html
Currently in your case i saw that there is no issue related to public_html (technically "Document Root" ) directory coz as your http://www.inspuratesystems.com/second/ is pointing to correct directory , and your documentRoot is parent of that directory, So if your documentRoot was wrong then there were no chance to access that that url, currently your domain is opening a correct index.html file which indicates that your documentRoot is there.
Create a index.html or home.html file there manually (from their web based file manager) and see if it is working or not, if it works then there is some issue with your uploading.
Your hosting provider seems to be dreamhost.com
Please check out this thread, according to which public_html seems to be a special case on dreamhost:
https://discussion.dreamhost.com/thread-144453.html
and/or this:
Getting a 'Not Found' error on my website?
Hope it helps!
Make sure that the public_html folder has execute permissions
chmod a+x public_html
That will allow execute permissions for everybody.
Perhaps it's possible that server (apache?) hides folders named public_html? Also check that group others have read and execute permissions for that folder.
In folder /path/to/second/ run
chmod ugo+rx .
chmod -R ugo+rx public_html
to set folder visible.
cpanel may handle the "public_html" folder in a unique way. Try uploading to a folder like: /home/yourusername/public_html/second/files/ instead of /home/yourusername/public_html/second/public_html/
If you are wanting to create a new distinct website at inspuratesystems.com/second/ you don't need a second "public_html" folder. Just put them in the /home/yourusername/public_html/second directory.
If you are using a linux or OS X server, you may need to change the permissions on the folder.
Did you checked if the folder is hidden attribute?
If you execute ls -a in terminal, you will know about it's existence. If it is present then please try giving it read & execute permission (using chmod 555 command). Give write permission if you are planning to write something or take feedback from users (using chmod 777).
I tried some of this options above but unfortunately none worked. Instead I discovered that in CPanel you have a "Preferences" tab and in that tab you have a "User Manager" function. You can there edit the ftp user that you created before in CPanel. On the "User Manager" funcion you can find the "Home Directory" configuration. On that home directory you just choose the "public_html". When you configure the user in the ftp account on your ftp platform, it goes directly to the path you defined in CPanel.

Mac Lion Apache can't view files in document root

Apache is running, localhost is working, if I put an index.html that works as well. However I can't access any folders (my websites) within the document root, which is /Users/Me/Sites
I get a forbidden error when I try to access these.
What's going wrong?
You should check the permissions of your home folder and your sites directory to make sure that they allow Apache access.
You could check the permissions, or just run (in a Terminal)
chmod o+x $HOME
chmod -R o+rX $HOME/Sites

Joomla Component Install Issue: Can't install any components, fresh install of latest Joomla

When I try to install any component, specifically my mtwMigrator component, I receive the following error:
* Warning! Failed to move file.
This is on a fresh install, with FTP Layer turned off, with default content installed, Joomla 1.5.14, latest PHP and my_SQL versions, Legacy mode turned on.
A very common cause of this error is due to file permissions. Joomla must be able to copy the files from your component into the components and administrator/components directories. If the system user the webserver runs as does not have write permissions to these folders, it will not be able to copy the files over.
The FTP layer is there to get around this issue. With the FTP layer on, you upload the component to the server first, then it is FTP'ed from the temporary directory to localhost. For this to work, the FTP user you specify must have permission to write to the components and administrator/components folders.
I had a similar problem when moving between machines (I know you said it was a fresh install - but someone might find this helpful). Ensure the $tmp_path entry in joomla\configuration.php is pointing to a valid directory. Mine wasn't.
In your Joomla backend, on the top menu, go to Help >> System Info >> Directory Permission and ensure that that are writable otherwise you don't want to have to change the folders to 777 and back again each time you install an extension.
In addition to this, you can mass chmod folders and files using Akeeba Admin Tools.
You mgiht also want to update to the latest Joomla 1.5 version (1.5.26)
The most ideal permission for Joomla directories is 755. There are cases when mod_suphp is not installed that the permission problem would occur.
Make sure that mod_suphp is installed and loaded by checking your php info e.g. and running this on your browser. If mod_suphp is not installed, then you will need help from your hosting provider to install this for you.
Normally, all directerories should have 755 (rwxr-xr-x) and all files 644 (rw-r--r--). If you want to set the most directories to not-writetable, you will need at least the directories listed in Help > System info > Directory Permissions. (Here you can also check which directories need to be changed, as non-writetable directories are shown in red.)
In some shared hosting environments, 755 / 644 isn't enough, as the owner of the file is not the (Web)Server User, but the FTP-User ... so either change it to 777 / 666 (not recommended, as you allow others to write your files), or get your FTP layer to work.
Another try: Joomla! does not work yet with the recent PHP 5.3. Can you use PHP 5.2? (Similar Problem in the Joomla Forum)

Resources