jquery on localhost - apache

I am using Linuxmint (= ubuntu linux 9.10)
I installed LAmp server which have apache,php mysql
and now i am trying to write jquery code
i made a file and it worked perfectly with this link : file:///var/www/jquery/jquery.html
but when i use this link, then it doesnt work anymore : http://localhost/jquery/jquery.html
the file jquery.min.js is in the same folder
and i already changed the src of it in source code to
<script type="text/javascript" src="/var/www/jquery/jquery.min.js"></script>
<script type="text/javascript" src="jquery.min.js"></script>
but none of them works (with localhost link)
using firebug I saw these errors:
The requested URL /var/www/jquery/jquery.min.js was not found on this server.
You don't have permission to access /jquery/jquery.min.js
on this server.
Apache/2.2.12 (Ubuntu) Server at localhost Port 80
so what do I have to do to make it run?

The second approach should work, if the apache server has read access to file /var/www/jquery/jquery.min.js.

If apache's user is wwwrun and the group is www, do the following:
chmod -R 0744 /var/www/
chown -R wwwrun:www /var/www/
This will ensure, that the apache user will have the rights to view, execute, etc. the files in your web-folder.

You also need to make sure your Apache configuration allows you to serve js files.
Try to access http://localhost/jquery/jquery.min.js and see if you can get the file.

Related

Laravel Ubuntu 16.04 returning status code 500

I just deployed a Laravel project I developed at localhost (using XAMPP) to a server.
I uploaded all files, created a new .env file (also got an app-key), ran composer install, created the db, ran artisan migrate.
Also, in
/etc/apache2/sites-enabled/000-default.conf I set the DocumentRoot to the public directory of laravel. Also I tried to edit the apache2.conf to include the directory, with Allowoverride All.
But entering the ip of my server, I get redirect to the login page (of course, I'm using the Auth of Laravel).
But I'm getting the error:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I tried to follow those steps, but it's all the same. Except the one point, that in my apache2.conf I don't wrote the DocumentRoot anymore, as I already set it in the 000-default.conf. I also tried to set it a second time in the apache2.conf, but this changed nothing.
So what couuld the problem be?
I'm using Ubuntu 16.04.
PS: Something seems to happen inside of laravel. When I go an existing route, I always get this error code 500. When I go to a route, that doesn't exist, I get an error (NotFoundHttpException), so the Routing itself kinda seems to work, but where does this error come from? It are exactly the local files I'm using with XAMPP, and locally it works fine... Any ideas?
EDIT: After editing my logs directory to have permissions like 777, I'm getting 2 errors as well.
Both point to storage/framework/views/ and storage/framework/sessions, saying "Permission denied". Do I just have to run chmod for those directories as well?
Check the error in storage/logs/laravel.log if there is no log there then make sure your directory permissions for storage allows it to be writeable 775 is what I normally use.
Okay, I got it, basically it was the permissions.
I now changed the owner of the storage folder to www-data. Now it's working (for anyone that might experience this problem, too).
if you use vps ubuntu, you have to set write/read permission with root folder (and all file, folder of it) by using this command on putty:
chown -R www-data:www-data /var/www/html
i tried this command, and my website doest not show 500 error

Apache can't serve DocumentRoot : no execute permission error

I am trying to migrate a web application from a Slackware config of Apache to a CentOS 7 one. DocumentRoot set to /home/STORAGE and there is a simple index.html file in it for testing. Both /home/STORAGE and index.html have 777 permissions set, yet Apache reports :
access to /index.html denied ... because search permissions are missing on a component of the path.
On the other hand, phpMyAdmin works fine, configured with a separate .conf file in /etc/httpd/conf.d . I tried using their example to make a .conf file for my app, but it still reports the same error. I don't even know where to start looking here.
EDIT:
I think this has something to do with the user of Apache. It is set to a local user in httpd.conf not to root, but the only pages the server serves are those in directories owned by root.
It was not a permission error but a Selinux issue. I decided to use the default /var/www/html for the application but still, had to allow write access to some dirs. Here is what I typed:
sudo chcon -t httpd_sys_rw_content_t /some/dir/in/var/www/html -R
The first time I typed it without -R and the permissions didn't change (check with ls -Z /dir/path). Now it is fine.

permission Apache PHP public_html

I'm newbie in the web development, and I'm trying to make a website. So, my website works fine on the server but not on my own (Apache). My sources are in ~/public_html/. The problem is I don't have permissions on the sub/sub directory, I mean, when it's a directory, it works fine, when it's directory in a directory, it doesn't. (403 Forbidden). I don't change my default Apache configuration excluding for include mysql and php.
All my directories have the same permissions. Maybe I need to configure something for that?
Thanks
I used this little script found at this link http://boomshadow.net/tech/fixes/fixperms-script/
Fixperms – for one single user
To use the fixperms script, simply log into your server as root, wget the file from our server, then run it. Type in the cPanel username and it will run only for that particular account.
It does not matter which directory you are in when you run fixperms. You can be in the user’s home directory, the server root, etc. The script will not affect anything outside of the particular user’s folder.
Should be done in SSH
root#example [~]# wget boomshadow.net/tools-utils/fixperms.sh
root#example [~]# sh ./fixperms.sh -a USER-NAME
Fixperms – for all of the users
If you would like fix the permissions for every user on your cPanel server, simply use the ‘-all’ option:
root#example [~]# wget boomshadow.net/tools-utils/fixperms.sh
root#example [~]#sh ./fixperms.sh -all

How to run my html file with apache2

Maybe it is not a right channel to ask this question but I donot know where to ask.
I want to know how to run html file with apache on my ubuntu. I have written program with javascript and a html file and I want to run it via apache. I could not find htdocs folder in to copy my files there beside that I do not have permission to do that in ubuntu. My apache is installed in /usr/share/apache2.
When I write http://localhost it says:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
but I do not know where to add the contents.
any help.
The default folder that it serves the HTML files from is /var/www.
For example, /var/www/test.html would be http://localhost/test.html.
In my case where I have installed and running the Apache 2 and if I type localhost/ into the browser it opens the Apache 2 Ubuntu default Page.
Now what I did was:
Suppose your HTML webpage Demo.html is located in the Website directory then copy the HTML page using one of the commands:
:~$ cp ~/Website/Demo.html /var/www/html
If this command does not work then try with the following command:
:~$ sudo cp ~/Website/Demo.html /var/www/html
And then open your browser and type this the browser search bar:
localhost/Demo.html
It will open the copied Demo.html.
Also if you want to access this hosted webpage from the outside of the machine where Apache 2 is running then use it's external IP address instead of localhost as follows:
ExternalIP/Demo.html

Apache 403 on certain folders

I'm running dev server on Centos 6.4 with Apache 2.2. I just moved a site from the production to dev to perform upgrades. I modified file owner to apache:apache (httpd user) and set all directories to 755 and files to 644. I have few other sites in the DocumentRoot folder with similar settings and they run fine (using same CMS, PHP, MySQL versions etc).
I have no virtual hosts defined and Allow all on everything. httpd.conf is default.
I'm not able to make site working from the folder I just moved from the production. I'm getting 403 every time.
As suggested in
https://serverfault.com/questions/272947/apache-on-centos-5-6-gives-me-permissions-denied-error/272956#272956
Usually that comes from Selinux not giving access to the folder. do
ls -alZ /var/www
and if the html folder doesn't have the context system_u:object_r:httpd_sys_content_t, fix it with chcon
chcon -v -R --type=httpd_sys_content_t /var/www/html
http://wiki.centos.org/HowTos/SELinux