Apache2 with web.py and php - php services not working - php

I have deployed my web.py application using apache2 and the configuration looks as follows.
<VirtualHost _default_ *:80>
ServerAdmin admin#project.com
DocumentRoot /var/www/html
ErrorLog /var/www/Engine/log/error.log
CustomLog /var/www/Engine/log/access.log combined
WSGIScriptAlias / /var/www/Engine/Engine.py
Alias /static /var/www/html
AddType text/html .py
WSGIDaemonProcess www-data threads=15
WSGIProcessGroup www-data
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
<Directory /var/www/html>
allow from all
</Directory>
Problem:
I have some php services hosted inside /var/www/html/apis . Those used to work before configuring with mod_wsgi, but when i request now, it says 404 error.
Question:
How to configure both Python and php services work together?

Try adding:
Alias /apis/ /var/www/html/apis/
Also see:
http://blog.dscpl.com.au/2014/09/hosting-php-web-applications-in.html

Related

How can I run my Laravel project without cmd command "php artisan serve"?

<VirtualHost *:80>
ServerAdmin webmaster#hujjaj.dev
DocumentRoot "C:\xampp\htdocs\hujjaj_app_new\public"
ServerName hujjaj.dev
ErrorLog "logs/hujjaj.dev-error.log"
CustomLog "logs/hujjaj.dev-access.log" common
I am doing so in my virtual host file and update 127.0.0.1 hujjaj.dev then i restart XAMPP and after that I navigate to localhost/hujjaj.dev but showing 404|Not Found.
Please try the following
<VirtualHost 127.0.0.2:80>
DocumentRoot “D:\laravel-gkb\public”
DirectoryIndex index.php
ServerName laravel-gkb.test
<Directory “D:\laravel-gkb\public”>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then add the save domain in your hosts file
127.0.0.2 hujjaj.dev
Refer this for more details : link
Yes, There is another way to run laravel project, with following command..
php -S 127.0.0.1:8001 server.php
This will run your application at 127.0.0.1:8001 mentioned address.
Note: laravel default entry point is server.php thats why we mentioned it. other wise it will be index.php

is it possible to configure PHP to use virtualhost

Actually, I downloaded PHP7.2.7 safe thread from PHP's website(php.net) and I don't know if it is possible I can configure PHP to setup a virtualhost like we can do using XAMPP
You can try below configuration:
1) Entry in hosts file as below
127.0.0.1 example.com
2) Set virtual host in httpd-vhosts.conf as below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example/public_html"
ServerAlias quickstart.com
<Directory "/var/www/example/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
PHP has a built-in web server, but is has limited capability. It does not provide all the configuration options a complete web server does. It does not do VirtualHost.
If you need VirtualHost, you will have to include it as a module inside Apache (or other web server). The module will be global. If your pages in a VirtualHost do not need PHP, PHP remains dormant and does nothing.
PHP isn't a web server, you need to create a VirtualHost in Apache. If you're using Linux, open up httpd.conf or /etc/apache2/sites-enabled/000-default.conf
and enter the following lines.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to restart your web server/apache in order to these changes to work.

php-fpm + bindfs not working

I'm trying to setup my local web server using vagrant. My vagrant shared folder is in my home folder (~/home/vagrant/www) and I want to use bindfs to mount this folder inside /var/www.
These are the specs of my virtual machine:
Apache/2.4.23 (Ubuntu)
PHP 7.0.12
Ubuntu 14.04
I am using php-fpm to execute php scripts but after using bindfs, my site will always return File not found.
Also here is my virtualhost configuration:
<VirtualHost *:80>
ServerName project1.dev
## Vhost docroot
DocumentRoot "/var/www/project1/public"
## Directories, there should at least be a declaration for /var/www/project1/public
<Directory "/var/www/project1/public">
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
<FilesMatch "\.php$">
Require all granted
SetHandler proxy:fcgi://127.0.0.1:9000
</FilesMatch>
</Directory>
## Logging
ErrorLog "/var/log/apache2/av_anhk5lpgjldb_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/av_anhk5lpgjldb_access.log" combined
## Server aliases
ServerAlias www.project1.dev
## SetEnv/SetEnvIf for environment variables
SetEnv APP_ENV dev
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
## Custom fragment
</VirtualHost>
Anyone can help me?
I manage to successfully run php-fpm + bindfs in my virtual machine. I just made sure that user who is running php-fpm and apache are the one I set in my bindfs command. My apache is run by www-user so I change my command to sudo bindfs -o perms=0755,mirror-only=www-user,force-group=www-data,force-user=www-user /home/vagrant/www /var/www and made sure that apache is also run by www-user.

Laravel virtual server routing doesn't work

I have installed newest Laravel on my Apache2. I run in Terminal
php artisan serve --port=8080
And It works. I have sub-pages and everything I need. But I want to have access without run this command.
I have next mylaravel.com.conf file in /etc/apache2/sites-available
<VirtualHost *:80>
ServerName mylaravel.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/mylaravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My Laravel files is of course in /var/www/mylaravel. In this configuration mylaravel.com works, but when I try for simple mylaravel.com/auth/register Apache return
When I used php artisan [...] this works fine. How can I fix it?
I had this same problem a while ago. From here:
If you don't have AllowOverride set to All, your Laravel .htaccess file (/public/.htaccess) won't be able to enable mod_rewrite, and your routes won't work.
Try adding the following to your <VirtualHost> block:
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>
So all up you'd have:
<VirtualHost *:80>
ServerName mylaravel.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/mylaravel/public
<Directory "/var/www/mylaravel/public">
Options All
AllowOverride All
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I found something. I added Sadurnias code and run in Terminal
sudo a2enmod rewrite
sudo service apache2 restart
Of course I changed chmod of /var/www to 755.
It's working fine, only when I run mylaravel.com/css FireFox doesn't end this request, but others is fine.

How do I share one set of files with two different domains in Apache?

I'd like to run my website in two different modes: dev, and test. I currently have the site set up in /var/www/mywebsite.com and working fine. Now I'd like to set up a different url that points to the same files, but has only one difference: apache's setEnv. I want to setEnv APP_ENV test so I can then hit http://test.mywebsite.com/ and read that APP_ENV in PHP. Is this possible?
If you want two distinct Apache setups, it is best to use Apache name-based virtual hosts. The key is to have two different configs, but use the same DocumentRoot. So for example this would be the Apache virtual host setup for mywebsite.com:
<VirtualHost *:80>
DocumentRoot /var/www/mywebsite.com
ServerName mywebsite.com
ServerAlias mywebsite.com
ErrorLog /var/log/apache2/mywebsite.com.error.log
CustomLog /var/log/apache2/mywebsite.com.access.log combined
SetEnv APPLICATION_ENV "prod"
<Directory "/var/www/mywebsite.com">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And then do this for test.mywebsite.com:
<VirtualHost *:80>
DocumentRoot /var/www/mywebsite.com
ServerName test.mywebsite.com
ServerAlias test.mywebsite.com
ErrorLog /var/log/apache2/test.mywebsite.com.error.log
CustomLog /var/log/apache2/test.mywebsite.com.access.log combined
SetEnv APPLICATION_ENV "test"
<Directory "/var/www/mywebsite.com">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I am assuming you are on an Ubuntu setup. So I would recommend putting them into two different files like this:
nano /etc/apache2/sites-available/mywebsite.com
nano /etc/apache2/sites-available/test.mywebsite.com
Then symlink the configs to sites-enabled like this:
sudo ln -s /etc/apache2/sites-available/mywebsite.com /etc/apache2/sites-enabled/mywebsite.com
sudo ln -s /etc/apache2/sites-available/test.mywebsite.com /etc/apache2/sites-enabled/test.mywebsite.com
Restart Apache like this:
sudo service apache2 restart
Then you should be in business with APPLICATION_ENV "prod" clearly going to mywebsite.com and APPLICATION_ENV "test" clearly going to test.mywebsite.com.

Categories