Error restarting httpd while installing phpmyadmin - amazon-ec2

After calling sudo service httpd restart I get the following error:
Starting httpd: Syntax error on line 2 of /etc/httpd/conf.d/phpmyadmin.conf:
Invalid command '\xe2\x80\xb9Directory', perhaps misspelled or defined by a module not included in the server configuration
And here's my /etc/httpd/conf.d/phpmyadmin.conf:
Alias /phpmyadmin /var/www/phpmyadmin
‹Directory "/var/www/phpmyadmin"›
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
#SSLRequireSSL
‹/Directory›
Any thoughts? My site is now down, can't seem to find the issue.
FWIW this is running on an EC2 Linux instance

Your <Directory> and </Directory> tags are using single arrow quotes instead of less than and greater than signs. Compare the slight difference: ‹ <.
Simply replace those characters with the proper less than and greater than, and you should be fine:
Alias /phpmyadmin /var/www/phpmyadmin
<Directory "/var/www/phpmyadmin">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
#SSLRequireSSL
</Directory>

Related

Apache 2.4 on Windows - Include folder out of DocumentRoot

I need to include a folder on my httpd.conf that is out of my DocumentRoot directory. I know there is a lot of info about this but not specifically for Apache 2.4 running on Windows. I tried a lot of things but anything works, I always get a forbidden error, and this is driving me mad.
Here is my default config made by WAMP:
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
That's OK but I need to include a folder project on my E:\ disk.
I have tried all of these, obviously restarting the apache server after every attempt:
Attempt #1
<Directory "e:/Development/[Git]/projectName/public/">
Require all granted
</Directory>
Attempt #2
<Directory "e:/Development/[Git]/projectName/public/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
Attempt #3
Alias /projectName "e:/Development/[Git]/projectName/public/"
# The <Directory> on attempts #1 and #2
Just to clarify:
I have tried a lot of combinations using / or \. Also using " or without. I even tried to escape the [] like this \[Git\].
I already have a VirtualHost well configured for that directory. I know it because if I remove the security on the <Directory /> then works fine, but as I have read this is a lack of security that I do not want to have:
# Disabling the security as below is not an option
<Directory />
AllowOverride none
Require all granted
</Directory>
Can anyone help me please? Thanks in advance

How to set Aliases or VirtualHost to run a laravel project on Apache2

I'm starting to learn how to set up a lamp on a vps, and i'm trying to run a laravel project.
This is my 000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
Alias /laravelproject /var/www/laravelproject/public
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
I'm trying to access using the /laravelproject and it works cause i'm redirected to a login page ip/laravelproject/login (like I set using the middleware for not logged users and it works on my local homestead virtual machine). But i got a 404 file not found error. Not a pretty designed laravel one, but a raw and ugly server error
Not Found
The requested URL /laravelproject/login was not found on this server.
Apache/2.4.10 (Ubuntu) Server at '' Port 80
Of course i don't have any laravelproject.com domain to set up, i want to access it simply with my_server_ip/laravelproject.
How can i set up a virtualhost or an alias to run it with all the routes working?
You could also try enabling apache mod-rewrite if not enabled yet.
sudo a2enmod rewrite
sudo systemctl restart apache2
You'll need to make sure the /var/www/laravelproject/public directory is set to AllowOverride All (which I believe you have taken care of by setting /var/www to All). Then make sure the .htaccess file in your public directory is correctly set up: https://github.com/laravel/laravel/blob/master/public/.htaccess
this is because Apache is looking for /public/login/index.html which is not a file. Laravel's .htaccess redirects these requests appropriately, but it has to be in your public folder and Apache has to AllowOverride
edit:
<Directory /var/www/laravelproject/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

Change localhost directory for Yosemite Apache 2.4

I have clean installed Mac OSX Yosemite but I cant configure the Apache 2.4 like I have always done on older OSX versions.
Here is what I want to do : set the "localhost" directory to "/Users/username/Public/".
But, everything I tried won't work, I always get a "Forbiden, can't access to /" or I get the default "It works!" page...
How to simply reroot my localhost ?
Thx
EDIT (thanks to Krister Andersson for the answer)
For Mac OSX 10.10 Yosemite
I also post the changes I had to do to keep things running.
In "/etc/apache2/users/", I created a file named by my username like this "myUsername.conf".
You can get your username by typing "id" in terminal. You should find your username at start in "uid=501(myUsername)".
In this new "myUsername.conf" file, just copy past this:
<Directory "/Users/myUsername/Sites/">
AllowOverride All
Options Indexes MultiViews
Options +FollowSymLinks
Require all granted
</Directory>
Dont forgive to change the myUsername value.
Then, in the "/etc/apache2/httpd.conf" file, uncomment all these two lines:
167 #LoadModule userdir_module libexec/apache2/mod_userdir.so
169 #LoadModule php5_module libexec/apache2/libphp5.so
Line 236, change the directory of "DocumentRoot" to whatever you want.
Line 250, set "Options" to "Options "Options Indexes FollowSymLinks Multiviews".
Line 258, set "AllowOverride None" to "AllowOverride All".
Line 263, set "Require all denied" to "Require all granted"
In Terminal, restart apache by typing "sudo apachectl restart".
It work's for me on Mac OS X 10.10 Yosemite clean install.
I've just installed Yosemite and I managed to change the DocumentRoot without any problems. First I modified the following lines in /private/etc/apache2/httpd.conf:
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks Multiviews
AllowOverride None
</Directory>
to:
DocumentRoot "<CUSTOM_PATH>"
<Directory "<CUSTOM_PATH>">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
</Directory>
The above will set a custom DocumentRoot, enable directory listing and allow configurations to be overridden by .htaccess files.
Then I restarted apache by executing sudo apachectl restart.
Another approach would be to set up a virtual host. First make sure so that the following line is uncommented in your /private/etc/apache2/httpd.conf file:
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Then you can add the following in the httpd-vhosts.conf file:
<VirtualHost *:80>
ServerAdmin webmaster#example.local
DocumentRoot "/Library/WebServer/Documents"
ServerName example.local
ErrorLog "/private/var/log/apache2/example.local-error_log"
CustomLog "/private/var/log/apache2/example.local-access_log" common
<Directory "/Library/WebServer/Documents">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
The above will setup a document root for a new virtual host named example.local and enable directory listing and allow configurations to be overridden by .htaccess files. Of course your also will need to restart apache for the changes to take effect:
sudo apachectl restart
On El Capitan you should restart apache with "-k" flag:
sudo apachectl -k restart

How to run apache webpage from multiple directories in the home folder?

Web Directory Structure
~/Sites/
./subdomain1.site.com/
./cgi-bin/
./subdomain2.site.com/
./cgi-bin/
~/Remote/
./subdomain1.remote.com/
./cgi-bin/
./subdomain2.remote.com/
./cgi-bin/
/private/etc/apache2/users/< username >.httpd:
<Directory ~ "/Users/<username>/Remote/.*">
Options Indexes Includes SymLinksIfOwnerMatch MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory ~ "/Users/<username>/Remote/.*/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
## Same thing as above, but using "Sites" instead of "Remote"
<Directory ~ "/Users/<username>/Sites/.*">
Options Indexes Includes SymLinksIfOwnerMatch MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory ~ "/Users/<username>/Sites/.*/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
I copied Sites into Remote and restarted apache (sudo apachectl restart) -- also, tried stopping, then starting to be thorough.
Directories contain the same permissions
index.html loads for the Sites directory, but not Remote, despite being the same file
URL looks like: http://localhost/~<username>/<directory in Sites or Remote>/index.html
There's nothing in httpd.conf that enables /apache2/users/<username>.httpd config, it just seems to work for Sites/, but not Remote/
In OSX-Mavericks, httpd.conf includes /extra/httpd-userdir.conf by default. This is where the "Sites" directory is being set.
Inside your setup, edit https-userdir.conf and add the line UserDir Remote. This should enable both directories in your home folder.

apache on windows virtual directory config help

I'm running Apache on Windows XP via Xampplite, and could use help configuring my virtual directory. Here's what I'm hoping to do on my dev box:
I want my source files to live outside of the xampp htdocs dir
on my local machine I can access the project at http://myproject
others on my local network can access the project at my.ip.address/myproject
keep localhost pointing to the xampp's htdocs folder so I can easily add other projects.
I've got 1 & 2 working by editing the windows hosts file, and adding a virtual directory in xampp's apache\conf\extra\httpd-vhosts.conf file. I don't immediately see how to do 3 without messing up 4.
Figured it out: use Alias for #3, instead of VirtualHost, thus:
Alias /myproject "C:/path/to/my/project"
<Directory "C:/path/to/my/project">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
To accomplish your list of needs.
1) Make the directory:
mkdir c:\xampp\sites\myproject
2) Edit c:\windows\system32\drivers\etc\hosts so it contains this line:
127.0.0.1 myproject
and add the following to c:\xampp\apache\conf\extra\httpd-vhosts.conf:
NameVirtualHost myproject:80
<VirtualHost myproject:80>
DocumentRoot c:/xampp/sites/myproject
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
3) Add the following lines to the end of c:\xampp\apache\conf\httpd.conf:
Alias /myproject/ "/xampp/sites/myproject/"
<Directory "/xampp/sites/myproject">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
4) Leave DocumentRoot, Directory, etc in c:\xampp\apache\conf\httpd.conf alone to accomplish this. For reference these lines would be:
DocumentRoot "/xampp/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
First enable: LoadModule alias_module modules/mod_alias.so
<IfModule alias_module>
Alias /ddd "D:/prj/customer/www"
<Directory "D:/prj/customer/www">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</IfModule>
Tested on WAMP 2.2 and its working: http:// localhost/ddd
In httpd.conf add the following lines, mutatis mutandis:
<IfModule alias_module>
Alias /angular-phonecat "C:/DEV/git-workspace/angular-phonecat"
</IfModule>
<Directory "C:/DEV/git-workspace/angular-phonecat">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
This worked great on my (Windows) XAMPP installation after restarting the Apache server. I had to add the "Require all granted", but otherwise it is pretty much the same as the above answers.
NameVirtualHost myproject:80
< VirtualHost myproject:80 >
< /Directory >
Must be:
NameVirtualHost myproject:80
< VirtualHost myproject:80 >
< /VirtualHost >
greets ;)
resolved the issue. it was missing the directory tag.
NameVirtualHost myproject:80
<VirtualHost myproject:80>
DocumentRoot "D:/Solution"
<Directory "D:/Solution">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Problem resolved in a simplest way and less steps
No Need of creating virtual host just change the location of target directory.
Here's what i have done for configuration:
I've done it by editing the C:/xampp/apache/conf/httpd.conf file
Changings that I have done in httpd.conf file
Added this script right after
ScriptAlias /cgi-bin/ "C:/xampp/apache)/"
Alias /projectXYZ "C:/pathtomyproject"
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Pathtomyproject = Complete path of project
And changed the url of Document Root
DocumentRoot " C:/pathtomyproject "
Now restart the Apache Server by stopping the server.
I have stopped Apache server, and then again started the Apache Server.
Source: http://bytespedia.blogspot.com/2013/12/creating-virtual-directory-in-apache.html

Resources