OctoberCms Backend not working in subfolder Apache - php

I am install a new project of the OctoberCMS in my VPS in a subfolder, example, /var/www/myCMS/ (here this my installation of the OctoberCMS).
When I access my site by domain example: www.mydomain.com/myCMS/ I having a image of the welcome demo, picture bottom:
But which accessing the Backend (www.mydomain.com/myCMS/backend I have this error:
Any solution?
My system is:
- Apache2
- Ubuntu 16.04

sometime default apache installation is not come with mode rewrite enabled( as you described its your vpn)
so you need to enabled rewrite module manually
use this 2 commands to enable rewrite module and restart apache
a2enmod rewrite
service apache2 restart
then just check that your directory have .htaccess in order to redirect all request to the index.php
in your apache server you need this things
<Directory /var/www/html/example.com/public_html>
Options Indexes FollowSymLinks
# this is needed to work .htaccess
AllowOverride All
Require all granted
</Directory>

Related

Apache+PHP - different php versions per VHost

On my local dev maschine (Ubuntu), I have apache2 and different php version to develop different projects, managed over Vhosts.
Is there a way to configure each vhost to use a specific (already installed) PHP version? So for example:
example1.local should use PHP 7.4
example2.local should use PHP 8.0
example3.local should use PHP 8.0
example4.local should use PHP 5.6
Currently, I am always running for example sudo a2enmod php{X} & sudo a2dismod php{Y} & sudo service apache2 restart to switch versions, which is really anoying.
I see you are using Apache. So you can use a .htaccess file and add there
AddHandler application/x-httpd-php74 .php
In this way your vhost uses php version 7.4
or with normal apache configuration
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
<IfModule mod_fastcgi.c>
AddHandler php74-fcgi .php
</IfModule>
</VirtualHost>

How to host .php files on apache2 - ubuntu?

I am hosting my web application for my maturita exam on google cloud. So I created VM (running on ubuntu) and installed apache2 on it. Then I installed PHP successfully. The problem is, it is hosting only .html files even though I installed PHP properly. When i try to host .php file an HTTP ERROR 500 will ocur.
The phpinfo.php is the only file thats working.
<?php phpinfo(); ?>
My question is. How do I change configuration of apache on Google clouds ubuntu?
PHP is the component of your setup that will process code to display dynamic content. It can run scripts, connect to your MySQL databases to get information, and hand the processed content over to your web server to display.
Once again, leverage the apt system to install PHP. In addition, include some helper packages this time so that PHP code can run under the Apache server and talk to your MySQL database:
sudo apt install php libapache2-mod-php php-mysql
This should install PHP without any problems. We’ll test this in a moment.
In most cases, you will want to modify the way that Apache serves files when a directory is requested. Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. We want to tell the web server to prefer PHP files over others, so make Apache look for an index.php file first.
To do this, type this command to open the dir.conf file in a text editor with root privileges:
sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
Move the PHP index file (highlighted above) to the first position after the DirectoryIndex specification, like this:
/etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
When you are finished, save and close the file by pressing CTRL+X. Confirm the save by typing Y and then hit ENTER to verify the file save location.
After this, restart the Apache webserver in order for your changes to be recognized. Do this by typing this:
sudo systemctl restart apache2
You can also check on the status of the apache2 service using systemctl:
sudo systemctl status apache2
An HTTP 500 error can be caused by a problem with your Apache configurations. If your code generate a 500 error, check to make sure they have permission to run in the directory where they are located. Apache will not allow programs to execute by default. So try to give permission to your virtual host directory with CHMOD.
And also for more details about the error you should check Apache error log like:
tail -f /var/log/apache2/error.log

Chevereto installation with mod_rewrite enabled

I try to install Chevereto free edition on Ubuntu 16.04 LTS with Apache 2.4.7. I get auto redirect to folder /install during installation process, which doesn't exists. /app/install/installer.php gives error message:
This file cannot be directly accessed.
Apache mod_rewrite is enabled. /install should be handled by index.php file.
Override has to be allowed in /etc/apache2/apache2.conf file.
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Laravel showing code of index.php on home page

I'm using Apache 2.4 on Ubuntu 16.04, it shows the content of the index.php in browser.
here's the code of my site's conf file:
<VirtualHost *:80>
DocumentRoot /var/www/laravel/public
ServerName laravel.dev
<Directory /var/www/laravel/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Why the home page renders index.php as text file?
Note: I have set 777 permissions to laravel folder. PHP is also installed.
I got the solution over here..
Actually, I had to install libapache2-mod-php and activate it i.e. a2enmod php7.0
add below command :
sudo apt-get install libapache2-mod-php7.2
(this will pull the default PHP version)
Reload Apache configuration changes by restarting service using below command
sudo service apache2 restart
I ran into same issue and was looking for answers. In my case I had multiple versions of PHP installed with all necessary libraries, including the one mentioned in answers above.
The cause of issue turned out to be not properly switching between PHP, which I do time to time while switching projects. Running again a2dismod php5.6 and then a2enmod php7.3 (switch from php5.6 to php7.3) and restarting apache did the job for me.
Hope this helps someone with similar issue like mine.

.htaccess not working in amazon ec2 ubuntu instance

I have a server from amazon's ec2 service running on Linux Ubuntu (
Ubuntu Server 13.04 64 bit) and I have installed apache, php, and mysql. I have added a .htaccess file in my document root (i.e /var/www/).
Here is the code in .htaccess file as follows:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
If I remove .php from url like "index1" instead of "index1.php", it returns 404 browser error. It works properly in my previous server.
I have .htaccess enabled in server. I did it using command "sudo vim /etc/apache2/sites-available/default" and changed "AllowOverride None" to "AllowOverride All".
I have also checked .htaccess working by passing invalid value in htaccess file and it returns "Internal server error - 500" in browser.
Here is the link of my server information : http://54.200.58.45/mytest.php
Any help in this regard will be highly appreciated.
This is wat worked for me on a fresh EC2 instance with Ubuntu 13.10:
a2enmod rewrite
vim /etc/apache2/sites-enabled/000-default.conf
add the following to the VirtualHost
<Directory "/var/www">
AllowOverride All
</Directory>
service apache2 restart
This happens because the rewrite module doesn’t come enabled by default for security reasons.
Create a new file called rewrite.conf in /etc/apache2/mods-enabled
in the file put this line LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
Now reload server sudo service apache2 restart
This worked for me and hopefully for you, but I don’t advice this for production servers. This is information for regular Ubuntu users not for a live server.
The problem is by default in apache installed on Ubuntu doesn't have .htaccess enabled so first you have to manually enable it in a config file and restart apache.
Here are the steps.
1) Login to your EC2 instance with SSH.
ssh -i "Yourkey.pem" ubuntu#yourpublicip
2) Enable Mode Rewrite, this is just incase if it's not enabled.
sudo a2enmod rewrite
3) Go to the following directory.
cd /etc/apache2/sites-available
If you use LS command here you will see the following file.
000-default.conf
That's the file with default apache configuration which is applied to your sites in /var/www/html folder.
4) Open this file for editing.
sudo nano 000-default.conf
5) Add following lines after DocumentRoot /var/www/html line.
Options FollowSymLinks
AllowOverride All
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
6) Save the file and restart the apache.
sudo service apache2 restart
that's it and now your .htaccess file will work
You need to check whether the mod rewrite module is enabled or not first.
Tried everything and nothing worked...
2 hours later.. Finally fixed it.
So first the things to rule out.
Make sure that you have made the changes in /etc/apache2/apache2.conf and in /etc/apache2/sites-enabled/000-default.conf that everyone is talking about... (AllowOverride All and AccessFileName .htaccess must not be commented out)
Make sure that the Directory /var/www/html is pointing to the right folder. Some times it has /html and some times it's just /var/www (however it must not end in / i think, but that might not matter.)
Finally, and this is what worked for me. Restart the whole server, not just Apache. I figured out that this was my problem, after i tried stopping apache2 (service apache2 stop) and I was still able to access my website. So I did a full reboot and then all the changes I have been making for the last 2 hours, finally kicked in.
Success :)

Categories