Opening ZF3 skeleton-application shows only source code but not the web page - zend-framework3

I setup a new development machine with my Mac.
Now I installed the zend framework skeleton-application.
When I open the url, it will show me the source code of index.php into my browser and not the web site.
Into /etc/apache2/httpd-vhosts.conf I added this:
<VirtualHost *:80>
ServerName test.dev
ServerAdmin info#abc.de
DocumentRoot "/Users/myname/Projekte/web/test/public/"
SetEnv APPLICATION_ENV "development"
<Directory "/Users/myname/Projekte/web/test/public/" >
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
ErrorLog "/private/var/log/apache2/test.dev-error_log"
CustomLog "/private/var/log/apache2/test.dev-access_log" common
What can I do to solve this problem?
Do I need a .htaccess at into my public directory?
Thanks for help.

Just to write a proper answer as the problem has been solved in comments.
So the problem was that an http request got back the source code as a response. Obviously, this is not a Zend Framework related question but rather a server configuration issue.
In order to properly diagnose the problem, one could use the most simple php code and directly try to access the script, hence dismissing the framework related issue. <?php phpinfo(); is a good test for instance.
Apache has two ways to make php interpreted: php-fpm and mod_php. One of those at least must be configured in order for Apache to pass the files to the interpreter.
In this specific case, the module was installed on the machine but not loaded in the configuration file, which has been done using the following line in apache config file:
LoadModule php5_module libexec/apache2/libphp5.so

Related

Symfony 5 - Installing API on VPS

i've installed a Symfony on my local LAMP. It works.
Then i've used the "composer require api" it works (with php -S 127.0.0.1:8000 -t public).
I've done the same thing on my VPS (same conf). Symfony OK. But API NOK without php -S domain.name:8000 -t public. But with php -S 127.0.0.1:8000 -t public it is working.
Here my VirtualHost :
<VirtualHost *:80>
# ...
DocumentRoot /var/www/html/A2SAPI/public
<Directory /var/www/html/A2SAPI/public>
AllowOverride None
Order Allow,Deny
Allow from All
# Copy .htaccess contents here
</Directory>
</VirtualHost>
<VirtualHost *:8000>
# ...
DocumentRoot /var/www/html/A2SAPI/public
<Directory /var/www/html/A2SAPI/public>
AllowOverride None
Order Allow,Deny
Allow from All
# Copy .htaccess contents here
</Directory>
</VirtualHost>
I don't know how to setup correctly the VirtualHost.
Thanks in advance
From the PHP docs:
Warning
This web server is designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
You should really look in to having Apache handle the PHP instead of using the PHP dev internal server. If you are looking for an easier alternative to Apache I strongly recommend Caddy server (https://caddyserver.com/)
Otherwise make sure Composer is either installed or that all dependencies of the api bundle have been copied to your server.

Error 503 Service unavailable

just started with Symfony2 and already have a problem that i can not solve.
Installed the Symfony2 demo app on a VPS with debian. but trying to open it give me a "503 Service unavailable".
I used 'symfony demo' to install to /var/www/symfony_demo/
then added a symdemo.conf file to /etc/apache2/sites-available that look like this:
NameVirtualHost XX.XXX.XX.XXX
<VirtualHost XX.XXX.XX.XXX>
ServerName symblog.dev
DocumentRoot "/var/www/symfony_demo/web"
DirectoryIndex app.php
<Directory "/var/www/symfony_demo/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
XX.XXX.XX.XXX = public server IP
and activated it with a2ensite symdemo.conf
I thought that would work, but opening the IP give me the error message.
and trying to open app_dev.php give me not allowed to access this file
Could someone please give me a tip?
Nevermind. Looks like i fixed it. Following this tutorial: http://intelligentbee.com/blog/2013/08/07/symfony2-jobeet-day-1-starting-up-the-project/
just activate mod_rewrite with a2enmod rewrite and restart apache. that's it.

Local wordpress website through two PCs

I have already installed XAMPP in my local computer and also a wordpress website. Is there any way to see the default page of my wordpress website (only the page, not the administration) from an another PC in the same network (home network)?
Having a URL such as http://example.dev/index.php instead of http://localhost/example/index.php is much clearer, works better with some website "extensions" involving paths and routing, and stored passwords are much easier to manage in browsers. Let's face it, it's just better all around.
EDIT: Since you've asked for external access (two PCs), I've changed this from my original configuration example, which is isolated from access except through the loopback interface. This example assumes your LAN is properly secured. Either firewall your LAN or change configuration as noted in commented portions of the configuration file to be more specific about access.
There are a few steps to get it working, but once you get used to the two files you'll work with, it's quite easy to set up a new project later.
Activate Modules in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule log_config_module modules/mod_log_config.so
Activate Virtual Host Settings in httpd.conf
#Listen 12.34.56.78:80
Listen 80
<VirtualHost *:80>
Comment out directory information
#DocumentRoot "E:/xampp/htdocs"
#<Directory "E:/xampp/htdocs">
...
Be sure to close the VirtualHost directive before the file includes:
</VirtualHost>
Configure Virtual Hosts Configuration File
After making the previous changes to Apache’s base-level conf file, you can work with the vhost extra conf file (%xampp%/apache/conf/extra/httpd-vhosts.conf).
<VirtualHost *:80>
ServerAdmin webmaster#myexamplesite.dev
DocumentRoot "C:\Users\JHaas\Documents\Projects\MyExampleSite"
ServerName myexamplesite.dev
ServerAlias myexamplesite.dev
ErrorLog "logs/myexamplesite.dev-error.log"
CustomLog "logs/myexamplesite.dev-access.log" common
<Directory "C:\Users\JHaas\Documents\Projects\MyExampleSite">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from none
Allow from all
#Allows a specific IP to access your VHost
#Allow from 10.0.0.24
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
Editing /etc/hosts
Finally, you edit the /etc/hosts file. This file is helps your system bypass the need for a DNS query, allowing you to create your own TLD (top-level domain) suffix such as *.dev, or anything that isn’t going to collide with current new top-level domain suffixes (*.me used to be quite popular until that suffix itself became a TLD suffix).
The localhost entry is not always required (depending on platform), and from my experience has actually caused problems if uncommented, so leave it commented out if it is already. If you see that localhost is not commented out (again, depending on your platform), be sure to leave it so. Changing the localhost entry from default can cause issues for many network services if it’s changed.
Also note that chrome has an issue with using *.local, so it’s probably best to avoid using this TLD suffix.
Host computer:
127.0.0.1 localhost
127.0.0.1 myexamplesite.dev
On the other computer, modify the /etc/hosts file to have an entry for your computer.
10.0.0.27 myexamplesite.dev
You can test your changes to the configuration files via command line using apache/bin/httpd.exe -t. This runs a syntax check on your configuration files.
Lets assume the ip of the pc running xampp is 192.168.0.198 and you are using the standard xampp setting regarding ports and the wordpress sites folder (testproject) sits in the xampp htdocs folder then you could access the site within the local network via:
http://192.168.0.198:8888/testproject/
Hope that helps. Best regards Ralf

Wordpress returns IP address instead of domain

This was working for years until I did something that has now jacked this up....
Searching on this topic landed me in several places that basically said: You need to check the Wordpress URL and the site URL in the general settings in Wordpress. I have done so and they are both: http://www.petesworkshop.com/blog_wp . Yet, when I hit that URL I am redirected to my internal IP and get a error http://10.0.10.206/blog_wp (yep, that would be wrong!
Interestingly enough, I can get to the admin page just fine and it is just a subfolder of blog_wp. So, somehow things directed to /blog_wp return the IP but everything else is OK. Wierd.
Wordpress sits behind an Apache proxy which has this directive for the virtual host:
<VirtualHost *:80>
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
ProxyPass / http://10.0.10.206:5080/
ProxyPassReverse / http://10.0.10.206:5080/
</VirtualHost>
The server running the website behind the proxy has this:
DocumentRoot "/www/petes/htdocs/petesworkshop/"
ServerName www.petesworkshop.com
ServerAlias petesworkshop.com
DirectoryIndex index.html index.php index.htm
ErrorLog logs/petesworkshop.log
Options FollowSymLinks
Alias /blog_wp /www/petes/htdocs/petesworkshop/blog_wp
<Directory /www/petes/htdocs/petesworkshop/blog_wp >
Order Allow,Deny
Allow From all
</Directory>
<Directory /www/petes/htdocs/petesworkshop >
Order Allow,Deny
Allow From all
</Directory>
I am not sure how I jacked this up...it is probably something that I did to the Apache configuration but I can't be sure since everything else behind the proxy works fine. I even tried adding specific ProxyPass entries for /blog_wp but that didn't make any difference.
Stumped...
Check your wp-config.php for correct urls
like below
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
This one turned out to be an Apache proxy issue. What I needed was to add 'ProxyPreserveHost On' to the configuration, which I thought I had in there originally but I either removed it in an edit or had it placed in the wrong virtual host. In any case, adding the ProxyPreserveHost On flag, took care of the issue. Not sure why other entries in the same virtual host DID work without it but I am not going to worry about it.
I had a similar problem some time ago, whenever I wrote my domain in the browser it was solved correctly but my domain name was changed by the IP, after much research it turned out that the problem was in the hosting, not in the server, so which only change the configuration of my domain in GoDaddy since I was only doing a redirection but the correct thing was to create an A record that points to # (which represents your domain name) and everything started to work correctly. I hope it's help

Hosting multiple domains in Apache2 - how?

Although I’ve found related articles on stackoverflow, I have seen various suggestions which I’ve tried out but I still experience problems, so that’s the reason why I’m posting this.
I have a question which involves DNS, Debian, Apache2 and Wordpress. I’ve been struggling with this for some time now and haven’t been able to solve it. My current conclusion is that 2there is something with my dns and apache virtual host definitions”, but, as I said I’m far from sure.
This is what my config looks like:
two domains which I “own” hosted by moniker.com - let’s call them domaina and domainb
a hosted vps with Debian, apache2 and wordpress. The vps has ip x.y.z.t
each domain has three ‘A’ records defined: ‘*’, ‘#’ and ‘www’
URL rewrite enabled (a2enmod rewrite)
Wordpress installed and links created to the wordpress directory for both document directories specified in the virtualhost directives below
Both ‘domaina’ and ‘domainb’ point to my vps and this is working ok. However, what I’ve been unable to solve is to have the vps handle “multiple virtual hosts”. I thought I would be able to handle this by using virtual hosts in Apache. For that purpose I’ve defined two sites under /etc/apache2/sites-available which looks like this:
(file: /etc/apache2/sites-available/domaina.com)
<VirtualHost x.y.z.t:80>
ServerName domaina.com
ServerAdmin me#domaina.com
DocumentRoot /var/www/domaina.com
DirectoryIndex index.php
<Directory /var/www/domaina.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
(file: /etc/apache2/sites-available/domainb.com)
<VirtualHost x.y.z.t:80>
ServerName domainb.com
ServerAdmin me#domainab.com
DocumentRoot /var/www/domainb.com
DirectoryIndex index.php
<Directory /var/www/domainb.com/>
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Now, when I try to address the sites above from a web-browser I end up at the default apache directory with the index.html file rendered in the browser instead of arriving at the two different wordpress configurations. Obviously there’s something wrong with my thinking around “VirtualHosts” and/or DNS-configurations…
I forgot to mention that I've made loads of /etc/unit.d/apache2 restarts... Sorry...
Frankly speaking I’m lost here and any help on this would be very much appreciated.
Cheers
If you did restart apache and its still not working please respond, as I have experienced similar issues with Apache, especially when getting the virtual host to work. I realise your running on Debian which is different to WAMP, but this is what I do when opening a new virtual host.
First I add the domain to the windows system 32 drivers etc hosts file, it allows for intranet
127.0.0.1 domainname and this stops the url from looking to the web.
Then I have to add the corret directories to the www/your folder.
Just inside the root folder there ought to be a directory called vhosts,
I had to make totaly empty instances of the conf files with just the filename of the virtual hosts inside it so that the changes you made to the httpd-vhosts.conf works.
So what you will need to do is find the wamp/bin/apache/Apache2.2.21/conf/extra/httpd-vhosts makes sure that you have the one from the conf/axtra and not conf/orginal.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/**name of the folder**"
ServerName **as_inserted_in_hosts**
<directory "c:/wamp/www//**name of the folder**">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
Save. Apache stop all services, I also have to restart the service running the intranet in windows to update the changes to the hosts file and then restart apache.
This is what I have to do so that when I open localhost from Apache it allows me to see the links appear under virtual hosts as well as the directories appearing under your projects.
Have a look at this tutorial... Explains how to set up virtual hosts
Do you have a NameVirtualHost directive in your apache2.conf anywhere? You'll need that to enable virtual hosting. It can go in apache2.conf or any file included by apache2.conf. On my server I've got it in ports.conf.
NameVirtualHost *:80
See http://httpd.apache.org/docs/2.2/vhosts/name-based.html#using

Resources