Apache2 at VPS without domain - apache

I want to use Apache2 at VPS to host my test websites.
Now I have a Joomla website and can reach it using 111.111.111.111/mydomain.com
But the troubles becomes when I trying to reach website's page like 111.111.111.111/mydomain.com/about.html
Not Found
The requested URL was not found on this server.
I think I need to configure apache right way but I don't know how.
Yes I know I can register some domain name but I prefer to use 111.111.111.111/mydomain.com address for now.
Thank you.

After many attemptions I had resolved it.
First of all you need to check the apache2.conf file. There must be active string AllowOverride All .
And next block
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then you need activate rewrite module
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
And better restart your Virtual Machine.

Related

Laravel Not loading inner pages in Ubuntu -- Not found with 404

I have developed a laravel web application and running fine on live server, now I am trying to migrate that project to a local server,
I am using Ubuntu 14.04 with built-in php, apache, and MySQL.
When I pointed in a browser like a localhost/xxxxxxx/ (Login page) that worked finely, after entering values in the login form it showed the 404 Not Found error.
How can I solve this, anybody please help?
This issue due to htaccess.
run
sudo a2enmod rewrite
Also change this in apache2.conf file located at /etc/apache2
nano /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Finally Restart Apache
sudo service apache2 restart
Working great. !!!!!

htaccess not working on EC2 Ubuntu instance

I am having an Amazon EC2 Instance, I have enable the mod_rewrite but htacess not working.
Also while changing /etc/apache2/sites-available/default setting AllowOverride none to AllowOverride All it is giving me internal server error.
Am I missing something.
internal server error.
Means there is something wrong with the .htaccess file likely
Check /var/log/httpd/error.log it may give you the line. but it will tell you whats wrong
Here is what I try and that work for me
Open file as
sudo vim /etc/apache2/apache2.conf
Second
remove comment sign (#)
AccessFileName .htaccess
Then find the line where there is
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverrideNone
Require all granted
</Directory>
replace "None" with "All"
AllowOverride All
I found this on https://webmasters.stackexchange.com/questions/61009/how-to-enable-use-of-htaccess-in-apache-on-ubuntu/61022#61022
Suppose It's showing some Internal Server Error First, you activate ModRewrite feature:
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart

.htaccess ErrorDocument 404 not showing up

I have a server from AWS EC2 service running on Linux ubuntu and I have installed apache, php, and mysql.
I have added a .htaccess file in my document root /var/www/html.
I entered this code in it:
ErrorDocument 404 /var/www/html/404.php and it is still not showing up.
I kept entered this command multiple times: sudo service httpd restart to restart the server but no changes displayed...
How can I fix this... Did I do something wrong?
First, note that restarting httpd is not necessary for .htaccess files. .htaccess files are specifically for people who don't have root - ie, don't have access to the httpd server config file, and can't restart the server. As you're able to restart the server, you don't need .htaccess files and can use the main server config directly.
Secondly, if .htaccess files are being ignored, you need to check to see that AllowOverride is set correctly. See http://httpd.apache.org/docs/2.4/mod/core.html#allowoverride for details. You need to also ensure that it is set in the correct scope - ie, in the right block in your configuration. Be sure you're NOT editing the one in the block, for example.
Third, if you want to ensure that a .htaccess file is in fact being read, put garbage in it.
An invalid line, such as "INVALID LINE HERE", in your .htaccess file, will result in a 500 Server Error when you point your browser at the directory containing that file. If it doesn't, then you don't have AllowOverride configured correctly.
Enable Apache mod_rewrite module
a2enmod rewrite
add the following code to /etc/apache2/sites-available/default
AllowOverride All
Restart apache
/etc/init.d/apache2 restart
If you have tried all of the above, which are all valid and good answers, and your htaccess file is not working or being read change the directive in the apache2.conf file. Under Ubuntu the path is /etc/apache2/apache2.conf
Change the <Directory> directive pointing to your public web pages, where the htaccess file resides. Change from AllowOverride None to AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I had the same problem and found the answer and explanation on the Ubuntu Ask! forum https://askubuntu.com/questions/421233/enabling-htaccess-file-to-rewrite-path-not-working
For Ubuntu,
First, run this command :-
sudo a2enmod rewrite
Then, edit the file /etc/apache2/sites-available/000-default.conf using nano or vim using this command :-
sudo nano /etc/apache2/sites-available/000-default.conf
Then in the 000-default.conf file, add this after the line DocumentRoot /var/www/html. If your root html directory is something other, then write that :-
<Directory "/var/www/html">
AllowOverride All
</Directory>
After doing everything, restart apache using the command sudo service apache2 restart
Most probably, AllowOverride is set to None. in Directory section of apache2.conf located in /etc/apache2 folder
Try setting it to AllowOverride All
Just follow 3 steps
Enable mode_rewrite using following command
sudo a2enmod rewrite
Password will be asked. So enter your password
Update your 000-default.conf or default.conf file located at /etc/apache2/sites-available/ directory. you can not edit it directly. so use following command to open
sudo gedit /etc/apache2/sites-available/000-default.conf
Or
sudo gedit /etc/apache2/sites-available/default.conf
you will get
DocumentRoot /var/www/html
OR
DocumentRoot /var/www
line. Add following code after it.
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Make user the directory tag path is same as shown in your file.
Restart your apache server using following command
sudo service apache2 restart
In my experience, /var/www/ directory directive prevents subfolder virtualhost directives. So if you had tried all suggestions and still not working and you are using virtualhosts try this ;
1 - Be sure that you have
AllowOverride All directive in
/etc/apache2/sites-available/example.com.conf
2 - Check /var/www/ Directory directives in /etc/apache2/apache2.conf (possibly at line 164), which looks like ;
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
If there is an AllowOverride None directive change it to
AllowOverride All or just escape line
By default, Apache prohibits using an .htaccess file to apply rewrite rules, so
Step 1 — Enabling mod_rewrite (if not Enabled)
First, we need to activate mod_rewrite. It's available but not enabled with a clean Apache 2 installation.
$ sudo a2enmod rewrite
This will activate the module or alert you that the module is already enabled. To put these changes into effect, restart Apache.
$ sudo systemctl restart apache2
mod_rewrite is now fully enabled. In the next step we will set up an .htaccess file that we'll use to define rewrite rules for redirects.
Step 2 — Setting Up .htaccess
Open the default Apache configuration file using nano or your favorite text editor.
$ sudo nano /etc/apache2/sites-available/000-default.conf
Inside that file, you will find a block starting on the first line. Inside of that block, add the following new block so your configuration file looks like the following. Make sure that all blocks are properly indented.
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
. . .
</VirtualHost>
Save and close the file. To put these changes into effect, restart Apache.
$ sudo systemctl restart apache2
Done. Your .htacess should work.
This link may actually help somebody https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04
I cleared this use. By using this site click Here , follow the steps, the same steps follows upto the ubuntu version 18.04
Go to /etc/apache2/apache2.conf
You have to edit that file (you should have root permission). Change directory text as bellow:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Now you have to restart apache.
service apache2 restart
In WampServer Open WampServer Tray icon ----> Apache ---> Apache Modules --->rewrite_module
For completeness, if "AllowOverride All" doesn't fix your problem, you could debug this problem using:
Run apachectl -S and see if you have more than one namevhost. It might be that httpd is looking for .htaccess of another DocumentRoot.
Use strace -f apachectl -X and look for where it's loading (or not loading) .htaccess from.
i have a lot of sites on my virtual machine,
and i solved it only by changing config of the site in which i needed .htaccess
what i did:
sudo a2enmod rewrite
next i changed only config for particular site, not for every site "example.com"
sudo nano /etc/apache2/sites-enable/example.com.conf
inside of it i added
<Directory /var/www/example.com>
AllowOverride All
</Directory>
service apache2 restart
so it only applies for 1 site, because when i tried to apply changes to entire server it crashed, don't know why, but this solved my problem

Website link shows Apache HTTP Server Documentation

My website directory /manual shows Apache HTTP Server Version 2.2 Documentation page i have removed this directory from my FTP but still o a, getting this.
I am using Linux Centos bellow is my manual.conf file configuration
There is a manual.conf which shows bellow configurations
#
# This configuration file allows the manual to be accessed at
# http://localhost/manual/
#
AliasMatch ^/manual(?:/(?:de|en|fr|ja|ko|ru))?(/.*)?$ "/var/www/manual$1"
<Directory "/var/www/manual">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
You may need to remove that link from your server configuration. If you have done this you need also to restart your apache server.
To remove the documentation look into your apache configuration (on Debian e.g. /etc/apache2/sites-enabled/000-default) for a block like this one here:
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
...
</Directory>
And comment them with # out. Than don't forget to restart the apache server to commit the changes.
After your update you seems to have two options:
Delete the whole file. That should remove the link for ever.
Comment all that lines out by adding a # to the beginning of all lines. This is for some cases better if you want to recover the manual in the future.
And restart the server with:
service httpd graceful
In fedora
dnf remove httpd-manual.noarch
service httpd restart
If you still have this behaviour and want to correct it just disable the apache2-doc conf and restart the apache2 service. a2disconf apache2-doc.

CakePHP webroot not accessible on new Apache setup

I've just set up a new Ubuntu 10.4 slice on Slicehost, and have installed apache, mysql and php. I've uploaded my CakePHP app and everything is running fine, except for the webroot being inaccessible. I have tried adding AllowOverride to all in /etc/apache2/sites-available/default and followed the Cake instructions to httpd.conf by adding
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all</Directory>
However, this is still not redirecting properly. I've hacked the css script tags to point to /app/webroot/css but would really like to know how to solve this issue properly. Any help would be much appreciated, this is the first time for me to setup a new slice, so apologies for the noobish question
For me this sounds like mod_rewrite problem. Could you check if you enabled your mod_rewrite in apache configuration?