I have the following environment:
XAMPP on Windows
php handled by mod_php5
Can someone please tell me how to load custom php.ini per project? because currently it only loads from the main php.ini of xamp setup.
Thanks a lot.
You can setup PHPINIDir for each virtual host.
Add to your apache configuration:
<VirtualHost *:80>
DocumentRoot c:\www\example1
ServerName www.example.com
PHPINIDir c:\www\example1
# Other directives here
</VirtualHost>
for handling several virtualhosts you should have different hostnames (you can use etc/hosts) or different ip-adresses.
Related
I'm setting up a windows server 2019 with apache 2.4 and PHP 5.6.
I was able to load the phpinfo in the browser with localhost.
I am trying to get the sites to open up in an htdocs folder on another drive (D:) using an alias that, according to our networking team is quoting, "DNS is set up correctly pointing to newprod.company.name.com", with "newprod" being the acutal alias.
In my httpd.conf file, I have the following settings:
Define SRVROOT "c:/Apache24"
ServerRoot "${SRVROOT}"
Listen 80
The above is pointing at the C: drive where Apache24 is located.
LoadModule rewrite_module modules/mod_rewrite.so
I have the above module uncommented. There are several other modules that have been uncommented, but the one above seems to be one of the main modules that, according to various Apache setup tutorials, is the main module.
ServerAdmin my.company#company.com
ServerName newprod.company.name.com:80
ServerName Localhost:80
According to various tutorials, the above seems to be accurate. I have compared my previous httpd.conf files, and they work using very similar configurations, including Localhost:80.
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
The main part to focus on above the D:/htdocs. This is where I figured the sites should be opening from, as well as opening using the alias.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
The above is typical for an Apache setup, per various tutorials.
<VirtualHost newprod.company.name.com:80>
ServerName newprod.company.name.com
Redirect / http://newprod.company.name.com/
</VirtualHost>
I use the above on another server (with a different alias) without any issues.
PHPIniDir "C:/PHP5.6"
AddHandler application/x-httpd-php .php
LoadModule php5_module "C:/PHP5.6/php5apache2_4.dll"
Then finally, the above is to ensure Apache will read PHP.
I have two other servers that are loading the sites with their own aliases with no problem. I literally went line for line trying to ensure everything matches. The only things that don't match is the PHP configurations at the bottom of the file. My other two servers are using PHP 7.4, while the problem server is using PHP 5.6.
Why aren't my sites loading using the alias I provided?
If you're using
ServerName newprod.company.name.com:80
ServerName Localhost:80
in main httpd.conf (or main apache config file), get rid of
ServerName Localhost:80
The vhost configuration
<VirtualHost newprod.company.name.com:80>
ServerName newprod.company.name.com
Redirect / http://newprod.company.name.com/
</VirtualHost>
is probably going to create a redirect loop: if that's all the configuration inside the virtualhost, get rid of it: it's useless.
Is port 80 on your apache server reachable from another pc? Are you able to telnet from a pc in the same lan on po 80 of apache server? Have you checked if the firewall is dropping the first syn packet?
I have a laravel app, which I test with php artisan serve.
I discovered that this is a bad practise, because it is not used on production.
I have installed apache2.4, it worked, when I open localhost I see 'It Works'.
Now I try to start my laravel app through apache on my PC.
For this I have done the following steps:
Edited the httpd.conf in Apache\conf, I uncommented this line:
LoadModule rewrite_module modules/mod_rewrite.so
Edited the httpd-vhosts.conf in Apache\conf\extra, I added:
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
</VirtualHost>
Edited the hosts file in Windows\System32\drivers\etc, I added:
127.0.0.1 www.localhost.eu localhost.eu
After every step I restarted the Apache2.4 service, but I still cant access my laravel application. The only thing, what changed is that I now get 'It Works' also on this domain: localhost.eu
What have I missed?
Currently I am starting my laravel app through php artisan serve. I can then access the app at localhost:8000.
Also I know I could set up homestead. But I discovered it too late. I have already configured and installed everything myself, and besides this one issue, everything works.
I'd like to understand how I would connect my laravel app to the apache server correctly myself.
Probably you forgot include file httpd-vhosts.conf file in httpd.conf. Sometimes this line commented by default and you should uncomment this line. After then you should restart apache2 service.
Add server alias on your file config
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
ServerAlias www.localcost.eu
</VirtualHost>
I am pretty new in PHP and moreover in Laravel and I am pretty desperate trying to deploy a Laravel 5.4 application that works fine on my local environment on my Linux remote server.
So I think that it is something related to virtual host configuration or something like this (maybe also something related to the .htaccess file)
In my local environment (I am using XAMPP on Windows) I have setted this virtual host into the C:\xampp\apache\conf\extra\httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/HotelRegistration/public"
ServerName laravel.dev
</VirtualHost>
So opening the laravel.dev URL I obtain the standard Laravel homepage (I have yet not replaced it with a landing page).
Then if I open this URL: http://laravel.dev/registration
I obtain the user registration page developed by me, this because I have this route into my web.php file into my project:
Route::resource('/registration', 'RegistrationController');
Then into my RegistrationController.php there is this method showing the resources/views/registration/index.blade.php view
public function index(){
return view('/registration/index');
}
All works fine.
Now I have uploaded this Laravel website into my remote Linux server, into this folder: /var/www/html/HotelRegistration
But now my problem is that in this remote environment I have not virtual host (correct me if I am doing wrong assertion: from what I have understand the virtual host is used on the local environment to simulate a domain that Laravel need to point to the public folder, is it this reasoning correct?)
Anyway, this is the URL of the public folder of my deployed web site on my remote server:
http://89.36.211.48/HotelRegistration/public/
As you can see opening it the Laravel landing page is correctly shown, the problem is that I can access to the previous registration page, the only way that I have found is to open this URL:
http://89.36.211.48/HotelRegistration/public/index.php/registration
but it is pretty horrible and above all when the registration form is submitted it is generated a POST request toward this URL http://89.36.211.48/registration that end into a 404 Not Found error.
So I think that it depend by the fact that in this remote server I can't use a virtual host that simulate a domain (as I have on my local environment), but I am not sure about it.
What can I do to solve the situation? Do you think that using a effective domain (something like: www.myregistration.com) that points to this directory of my remote server http://89.36.211.48/HotelRegistration/public/ I can solve this problem?
You need to configure your domain in your server and need to reconfigure the apache. I'm considering you are having apache2 server so here you can do:
Step 1 Go to the apache2 folder cd /etc/apache2
Step 2 You can see sites-available folder go inside it cd sites-available
Step 3 Make a new file name it laravel.dev.conf
Step 4 Write down the following sudo nano laravel.dev.conf
Step 5 Write down the following option:
<VirtualHost *:80>
ServerAdmin webmaster#laravel.dev
ServerName laravel.dev
ServerAlias www.laravel.dev
DocumentRoot /var/www/html/laravel.dev/public/
ErrorLog /var/www/html/laravel.dev/logs/error.log
CustomLog /var/www/html/laravel.dev/logs/access.log combined
<Directory /var/www/html/laravel.dev/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
Step 6 Now go to this folder/create a new one cd /var/www/html/laravel.dev
Step 7 Copy/Install your laravel application here.
Step 8 Now you can enable your site by typing sudo a2ensite laravel.dev.conf
Step 9 Now restart the apache2 sudo service apache2 restart
Now you can have proper access to your domain. Hope this helps.
Since you are using XAMPP
Add the following into your VirtualHost Directive:
<Directory "LINUX PATH TO /HotelRegistration/public">
AllowOverride All
</Directory>
Your final VirtualHost Directive should look like:
<VirtualHost *:80>
DocumentRoot "LINUX PATH TO /HotelRegistration/public"
ServerName 89.36.211.48
<Directory "LINUX PATH TO /HotelRegistration/public">
AllowOverride All
</Directory>
</VirtualHost>
After the configuration changes, restart Apache then you are good to go.
I want to create virtual hosts for my project in zend framework. I have frontend and backend (admin) functionality. I created the virtual host for my frontend functionality with necessary configuration and it running properly.
Example: In /etc/apache2/sites-available I created the file roomstays and my code is in var/www folder.
<VirtualHost *:80>
DocumentRoot "/var/www/roomstays/public"
ServerName localhost
#This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/roomstays/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And it running properly with localhost.
Now I have admin i.e.backend code and as previous one I want to run this code. I put my newer code into same var/www directory with named roomstaysback. My question is how to create virtual host for this backend code. I want to run both frontend and backend side code.
Please give me any solution I am completely new in it thanks.....
You can handle both front end and back end from same virtual host. zend framework provides the concept of modules. Here is one example. Have a look
Setup multi modules in Zend Framework v1.9 with 13 steps
and the detailed one is here
Using a Conventional Modular Directory Structure
1.Create a conf file for virtual host
$sudo gedit /etc/apache2/sites-available/HOST_NAME.conf
2.then paste following contents to this file
<VirtualHost *:80>
ServerName www.HOST_NAME.com (set host name here)
DocumentRoot /var/wwww/HOST_FOLDER (point to host path )
</VirtualHost>
Add host name
$sudo gedit /etc/hosts
Then paste following contents
127.0.0.1 www.HOST_NAME.com
enable the site
$sudo a2ensite HOST_NAME.conf
Restart apache server
$sudo service apache2 reload
The process is over and you can browse www.HOST_NAME.com :)
I am looking for a way to have multiple-level subdomains on a server running Apache2.2 and PHP5. Ideally the solution will be in Apache and not PHP.
For instance:
www.apps.example.com OR
test.apps.example.com
I've seen this on commercial sites before but have not seen any solutions for how to implement this. I essentially want to allow users to either enter www before any subdomain or just to enter the subdomain without the www's. so both x.example.com and www.x.example.com resolve to the same directory.
I am running CentOS 5.4 & Ubuntu 8.04, PHP 5.2.10 & Apache 2.2
Thanks
You can dynamically add entries into apache config files using a PHP language, But remember you are living on edge of uncertainty
// add this to your httpd.conf
Include extra/httpd-vhosts.conf
// add this to extra/httpd-vhosts.conf
<VirtualHost *:80>
// with www prefix
DocumentRoot /www/example/x
ServerName x.example1.com
ServerAlias www.x.example1.com
</VirtualHost>
<VirtualHost *:80>
// without www prefix
DocumentRoot /www/example/x
ServerName x.example1.com
</VirtualHost>
You can do that by adding apache virtual hosts. A bunch of great examples can be found here: http://httpd.apache.org/docs/2.0/vhosts/examples.html