I'm facing to a problem I didn't have before.
I have my local LAMP server root folder in /home/franck/www
I managed to do so to seperate my working flow from the system, just in case and also because this is how most servers I'm working with are setup.
What I did :
sudo chown -R www-data:www-data ~/www
sudo usermod -a -G www-data franck
sudo chmod -R ug+rwx ~/www
I didn't have this permission error before. I just updated php5 to 5.5 via ppa, don't know if it's the reason. I'm still having 403 error permission.
Could someone help ?
<VirtualHost ....>
ServerAdmin neovea#gmail.com
ServerName dev.atomik.me
ServerAlias dev.atomik.me
DocumentRoot /home/franck/www/atomik
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/franck/www/atomik/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
All right ! I found the solution !
I really don't know why it now works this way, but after googleing and stacking a bit more ahead, it appears that files in sites-available must be named *.conf before being enabled.
I did so, deleted my files in sites-enabled and enabled it again. Worked perfectly.
But I'm still wondering why I didn't have to do so before, and now I do... Mystery. Maybe an update from Apache2 ?
If someone know, I'm really interested. So after all my permissions were right. I hope that'll help.
Thanks a lot for the hand ;)
Related
I have Wordpress installed using an AWS EC2 instance. The public IP is as here. I used LetsEncrypt to get SSL, that worked fine. But after that, my homepage now shows the 'Apache2 Ubuntu Default Page'. It should be showing me the Wordpress homepage. I still have ssh access to the EC2 (Bitnami Wordpress), so my data is supposedly still there.
I've been doing some research at it seems that I need to change something with Apache so it direct to the Wordpress directory/page.
Any help in the matter would be most appreciated :)
Bitnami Engineer here,
It seems you installed the Apache2 system's service in the machine and it got started at boot time. The Bitnami apps don't use the system's services. That's why the Bitnami's Apache service can't be started because other service is already running in the 80 port. In order to stop and disable it, please run these commands
sudo service apache2 stop
sudo service apache2 disable
sudo /opt/bitnami/ctlscript.sh start apache
Happy to help!
The fact that you're getting the Apache default page is a good sign, it means everything from a networking standpoint is working correctly. Now, you just need to show Apache where to serve your files.
Apache stores their default configuration typically in /etc/httpd/httpd.conf or /etc/apache2/sites-available/default and looks something like below.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Before making changes to this file (whenever you find it), you will also need to know where the DocumentRoot is. This is essentially the directory that your index.php is located. In the example above it's located in /var/www, and that's typically a good place to start looking.
If you're having a hard time finding your root directory, you can do something like find / -type f -name "index.php".
Assuming your index.php is in /var/www/wordpress your configuration could look as simple as this.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/wordpress
</VirtualHost>
I am using Ubuntu machine. I am running lampp server for php files.
I have all my PHP files in my_folder where I have all my codes in /opt/lampp/htdocs/my_folder including index file in /opt/lampp/htdocs/my_folder/index.php.
I wanted to check my codes by running http://localhost/index.php in Chrome browser, but for some reason it keeps directing me to /var/www/html/html.index file. Can someone please help me resolve this problem?
Thanks in advance.
add this to you apache config.
DocumentRoot /opt/lampp/htdocs/my_folder
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /opt/lampp/htdocs/my_folder>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Adittionally, If MySQL doesn't start:
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/mysql stop
sudo /etc/init.d/proftpd stop
sudo /opt/lampp/lampp start
I have 2 problems:
when I run:
file_put_contents("/etc/apache2/sites-enabled/www.mydomain.com.conf",$vh);
I get the error: failed to open stream: Permission denied
How do I safely reload apache (after adding a domain) from PHP.
I don't think $res = shell_exec("sudo service apache2 reload") is working, I dont get anything in return.
Its a bad practice, why don't you go and create a default virtual host that will answer to any domain.
In the app level you can do some protections about it.
This way you are shortening your code to the minimum.
He is an example (dont use it as it is, needs to be tested):
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/the_site>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You definitely do not want to do as PHP, but you might try the following approach: modify the sudoers file to grant your apache the ability to sudo a single command:
root ALL=(ALL) NOPASSWD: /usr/local/bin/php_add_vhost
Then you create an executable script (either bash or php, python or whatever) which reads the data from a specific location, puts it in the /etc directory and does a "service apache2 reload".
This approach has many security problems, but if you are asking this question you are probably good to go anyway.
I have a symlink mysite in my /srv/http/ folder pointing to /home/some-user/somefolder.
In my /etc/httpd/conf/httpd.conf, according to many thread in this site and other forums all around the Internet, I set the following:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
DocumentRoot "/srv/http"
<Directory "/srv/http">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then I changed permission to 777 recursively to my symlink target folder like this:
chmod 777 -R /home/some-user/some-folder
But if I open my webbrowser and enter http://localhost/mysite/mypage.php I get the following error:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.9 (Unix) PHP/5.5.14
I've read many articles saying to do so, but I still can get it working...
You should chmod o+x the entire path where apache'd go through.
So in your case:
sudo chmod o+x /home/
sudo chmod o+x /home/some-user/
sudo chmod o+x /home/some-user/somefolder
Ok, found out! I needed also chmod o+x /home/some-user (parent folder to my site folder)
In order for me to be able to run a Zend Framework project on my local development machine, I made changes to Apache's \etc\apache2\httpd.conf and the openSUSE system's \etc\hosts files. I set up a test3.local alias for an individual Zend project, and things seem to "work".
Before I started fiddling with things, I could access phpMyAdmin simply by entering http://localhost/phpMyAdmin/ in my browser. And if I take away my changes, that once again works.
Using this answer as a basis, I tried to set up an additional virtual host specifically for phpMyAdmin, hoping to "solve" this problem. But right now if key in the virtual host name, admin.local, that I intend to take me to phpMyAdmin, I get a 403 error like this:
(source: willmatheson.com)
Here is my present httpd.conf:
### Virtual server configuration ############################################
IncludeOptional /etc/apache2/vhosts.d/*.conf
<VirtualHost *:80>
ServerName test3.local
DocumentRoot /home/william/public_html/ZendTest3/public
SetEnv APPLICATION_ENV "development"
<Directory /home/william/public_html/ZendTest3/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName admin.local
DocumentRoot /var/lib/mysql/phpMyAdmin
# This gives permission to serve the directory
<Directory /var/lib/mysql/phpMyAdmin>
DirectoryIndex index.php
Options None
AllowOverride All
# This allows eveyone to access phpmyadmin, which you may not want
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
and hosts:
127.0.0.1 localhost
127.0.0.1 local
127.0.0.1 test3.local
127.0.0.1 admin.local
Ideally I'd like to not have to specify a virtual host for phpMyAdmin at all, because I'm sure to muck it up, and just somehow have the settings to make the Zend project work but to also have phpMyAdmin work like it did before.
I know this question was already answered, but I thought I'd share what I did to overcome a similar problem, in case it helps anyone else.
My problem was:
I started to get localhost/phpmyadmin 404 error after changing the DocumentRoot folder in httpd.conf. The change I made was to change the DocumentRoot
from:
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs"
to:
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs/a/deeper/folder"
I fixed it by changing a line in zend.conf
from:
Alias /phpMyAdmin "C:\Program Files (x86)\Zend\phpMyAdmin"
to:
Alias /phpMyAdmin "C:\Program Files (x86)\Zend\ZendServer\data\apps\http\__default__\0\phpMyAdmin\4.0.5.4_41"
Hope this helps somebody else!
Well, there's a good reason I was getting a 403 - I was digging in the wrong place. My installation of phpMyAdmin was actually in /srv/www/htdocs/phpMyAdmin. Changed that, restarted Apache (sudo systemctl restart apache2.service) and things seem to work.
If you're interested in how the heck to find files and folders on openSUSE, the following steps worked for me:
sudo zypper install findutils-locate
su
updatedb (go check your e-mail)
locate phpMyAdmin (like that, not 'phpmyadmin')