Cannot get site loaded with Apache on Mac - macos

I'm running El Capitan and trying to get my website hosted locally for development with Apache (that came with the OS). I followed the instructions here exactly. I made an anthony.conf file and put the Directory text in there, I replaced the actual directory with /Users/anthony/dev/web/unfinished-asteroids/ and then placed my web files in there. I started apache and navigated for localhost/~anthony but I get the
Not Found: The requested URL /~anthony was not found on this server.
standard 404 error. When I navigate to localhost it works fine and I get the "It works" from the index.html that is located in /Library/WebServer/Documents, I even changed that index.html file and it works fine.
Any ideas why I'm not able to see my website using apache? All I did was download this github repository and place it in my unfinished-asteroids folder, the index.html is at the root.

So it looks like there are a couple of extra steps that you need to do. There isn't really anything too special about apache that comes with OSX, so your standard apache configurations will work. but to get Userdir (~username) working on El Capitan,this is what I had to do
Edit /etc/apache2/httpd.conf
on (or near) line 166, uncomment
loadModule userdir_module libexec/apache2/mod_userdir.so
then on line 493 uncomment
Include /private/etc/apache2/extra/httpd-userdir.conf
then edit file /etc/apache2/extra/httpd-userdir.conf
uncomment line 16
Include /private/etc/apache2/users/*.conf
then in /etc/apache2/users/anthony.conf
<Directory "/Users/anthony/Sites/">
Options Indexes MultiViews
Require all granted
</Directory>
then sudo apachectl restart
That should make http://localhost/~anthony point to your sites directory.
Logs are stored in /var/log/apache2
Now if all you want is web access to say your dev directory you can do something like this.. (don't make any of the changes listed above)
in /etc/apache2/other/ create a file called mydev.conf (name doesn't really matter, save it needs to end in .conf')
and put this in that file
Alias /dev /Users/anthony/dev/
<Directory "/Users/anthony/dev">
Options Indexes MultiViews
Require all granted
</Directory>
and reload apache (sudo apachectl restart)
then you will be able to access your dev folder at http://localhost/dev and should be able to access your page at http://localhost/dev/web/unfinished-asteroids/
you can adjust the paths at will above, just need to make sure that the user or group _www has access to it, and that paths in the alias and the directory match.

Related

Laravel 5.5 CRUD on Chrome

I am currently trying to run the program after I have successfully created all the necessary CRUD files. Note that I am following this tutorial here.
However, I am facing problem in trying to run the sites from my cmd. I tried taskmanager.dev but Chrome returned 'This site can’t be reached'.
May I know, is the any specific ways for me to run the site on xampp?
I am using Windows.
Please help. Thank You.
I am quite sure the guy who made the tutorial is using valet.
Just use php artisan serve and you will be able to connect to your site on localhost.
But if you really want to use taskmanager.dev do the following:
Open the hosts file, which is lotcated # C:\Windows\System32\drivers\etc\hosts
Add 127.0.0.1 taskmanager.dev at the bottom
Make sure you follow their installation tutorial closely. It sounds like you may not have configured the server correctly.
For me, I have to edit my VHosts file which is in:
C:\xampp\apache\conf\extra
And to edit my hosts file I need to go to:
C:\Windows\System32\drivers\etc
If all else fails you can always just run php artisan serve in bash to launch your app.
But I would recommend going through these instructions again:
XAMPP Virtual Host
We need to configure XAMPP Virtual Host to set the document root to correct directory of laravel project and to also assign a name to the project by which we will be accessing it in browser.
Navigate and open file /Applications/XAMPP/etc/httpd.conf file and uncomment the line that includes the virtual host file.
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Navigate and open file /Applications/XAMPP/etc/extra/httpd-vhosts.conf and include following Virtual host entry in this file.
# VirtualHost for TASKMANAGER.DEV
<VirtualHost taskmanager.dev:80>
DocumentRoot "C:\xampp\htdocs\taskmanager\public"
ServerAdmin taskmanager.dev
<Directory "C:\xampp\htdocs\taskmanager">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
With this entry our apache is listening to taskmanager.dev, but we also have to edit our hosts file to include an entry for the new domain.
Edit file /etc/hosts and add following entry to that file.
127.0.0.1 taskmanager.dev
Restart your apache and access taskmanager.dev on your browser you should be able to see this screen.
Chrome 63 now enforces .dev domains via HTTPS. Follow this article : https://laravel-news.com/chrome-63-now-forces-dev-domains-https to know more.
I've changed to .test for my valet domains. Hope this helps. Thank you.

localhost/~username/ not working

So i have stuck on this thing since last week . i am new to web development , and wanted to learn php , as soon as i started i had to setup apache server , for root directory it works fine but for localhost/~username/ it can't connect to server "localhost".
here are the files i had been messing up
(sudo apachectl configtest : Syntax OK )
httpd-userdir.conf file
https://www.dropbox.com/s/3zmuc2jetpo3i0i/httpd-userdir.conf?dl=0
httpd.conf file
https://www.dropbox.com/s/vlrzqr95ge2qy3c/httpd.conf?dl=0
username.conf file
https://www.dropbox.com/s/f13cgfgfb56esi7/mfaizanulhaq.conf?dl=0
(OS X el Capitan
10.11.5 (15F34)
&
Server version: Apache/2.4.18 (Unix)
Server built: Feb 20 2016 20:03:19
)
If this is still relevant and you are fed up with trying to find a solution you can change Documents root folder to your user Sites folder. This will prevent everyone but you from accessing localhost from your machine, but it's a hotfix solution. I've had a deadline and I had to finish the site, so this worked for me.
Go to httpd.conf change
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
to
DocumentRoot "/Users/username/Sites"
<Directory "/Users/username/Sites">
To look up your username in the terminal use whoami.
NOTE: Bear in mind you also need to change the following lines in httpd.conf it's located just below DocumentRoot within <Directory> tag you changed earlier.
Whatever it says in your file modify to this (that should be true for ALL configurations of the Apache2)
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
This is a really bad solution since your Users/username/Sites folder will be accessed directly when you type localhost in the browser, but when something goes wrong, or you've done something wrong this is the best solution so far especially if you are 100% certain you are not going to have more than 1 user access your localhost directory.
i hope no one faces this problem. In my case i had updated php to php 7 but in httpd.conf it was trying to load php 5 so by commenting out that line my problem was solved.

Apache 403 when hitting name.local Yosemite

This is the first time I'm setting up an apache web server, I'm doing this on my Mac with OS X Yosemite. For some reason I'm receiving 403 errors when I try to hit my user directory via the browser with the formate computerName.local. When I hit the default directory with that same format I get the "It works!" page, but when I try to hit my user directory it gives me the "Forbidden" error... If I hit it with localhost everything works fine, but I'm trying to hit it from my iPhone hence the localhost won't work from there...
I've tried every guide I could find, tried setting the vhosts configuration file (but when I do so the browser can't reach the folder even when trying localhost), I tried changing the httpd.conf file to have "Require all granted" on a new with the path to my user sites directory... Can anyone tell me if I'm doing something wrong? If you need I could upload my httpd.conf and httpd-vhosts.conf files (or any other related file that may need configuration).
Thanks!
Found the issue. It took me a while but it was really simple at the end. On my User conf file /private/etc/apache2/users/USERNAME.conf there was a line that was absolutely responsible for the behavior that from localhost everything worked fine but from computerName.local it wouldn't. This is what the file looked like:
<Directory "/Users/Santiago/Sites/">
AddLanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from localhost
Require all granted
</Directory>
All I had to do was change that "Allow from localhost" to "Allow from all" and restart apache. Everything works now.

Cannot see contents of directory with local Apache

I have set up apache2 on my Win7 box and would like to be able to see the contents of a directory.
For example, I would like to navigate to:
http://localhost/tutorial/
and see a list the different html, js, and css files I have created. I've already redirected Apache to check the C:\ApacheHtDoc\ folder as the source directory. I've tried looking at folder permissions, but I'm not sure how to see the contents of the C:\ApacheHtDoc\ directory and the subfolders I'm bound to create.
Have you added the directive in Apache2.2\conf\httpd.conf
<Directory "C:\ApacheHtDoc\">
Options Indexes FollowSymLinks
Order Allow,Deny
Allow from All
</Directory>
If you haven't, add that and restart apache.
Edit
Path for the httpd.conf may vary according to your install.

Error getting images to show up in Symfony 1.4.8

Note: It was tough deciding whether this belonged here or ServerFault, but it seemed like a programming problem, so if it's out of place, feel free to migrate it.
I downloaded the sandbox of Symfony 1.4.8 and copied the files to my webserver. Unfortunately, when I try to access /symfony/sf_sandbox/web/ (where I installed it), I get the following:
It seems like the images aren't showing. According to the text:
If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory.
However, when I try to locate the folder referenced above, it does not exist:
sf_sandbox
web
css/
images/
js/
uploads/
frontend_dev.php
index.php
robots.txt
As you can see, there is no sf/ directory under web/. What am I doing wrong?
Note: I am installing this on Ubuntu 10.04 64-bit using Apache.
All the images are located in the Symfony source directory.
I would try creating a symbolic link in the web folder called sf pointed to the following:
lib\vendor\symfony\data\web\sf
It should have access to the needed images at that point.
This is done by indicating the right path in the Alias directive in your apache configuration:
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
Listen 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Just replace "/home/sfprojects/jobeet" with your project's path and it should work.
This page shows the apache config to set up a new project correctly.
There are also important security notes for your webapp.
Symfony Documentation
All you need to do is copy the whole sf folder to the web folder. In my case i copied c:\wamp\www\jobeet\lib\vendor\symfony\data\web\sf\ to c:\wamp\www\jobeet\web. Hope that makes sense

Resources