Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am running Apache 2.4 on Redhat 7.2, I have also installed PHP 5.6.
I created a vhosts file for a site
<VirtualHost *:80>
DocumentRoot /var/www/html/ex1.mysite.com
ServerName ex1.mysite.com
ErrorLog logs/ex1.mysite.com-error-log
CustomLog logs/ex1.mysite.com-access_log common
<Directory /var/www/html/ex1.mysite.com>
AllowOverride AuthConfig FileInfo
Order allow,deny
allow from all
</Directory>
I am able to view index.html in my browser, however when I attempt to load a PHP file, I get a message "File Not Found". I am able to view a PHP file in the default location (var/www/html).
Is there a way to get PHP working in a virtual host?
I am able to view index.html in my browser, however when I attempt to load a PHP file, I get a message "File Not Found". I am able to view a PHP file in the default location (var/www/html).
Is there a way to get PHP working in a virtual host?
Since you can view php pages in docroot, you should be able to also view php in the subdirectory /var/www/html/ex1.mysite.com
Perhaps you did a typo giving the "Not Found" error. Check the apache error_log (ex1.mysite.com-error-log) to see what you get from it.
Since you can view php pages in docroot, you should be able to also view php in the subdirectory /var/www/html/ex1.mysite.com
Perhaps you did a typo giving the "Not Found" error. Check the apache error_log (ex1.mysite.com-error-log) to see what you get from it.
Regards
Thanks bathory, I am not doing a typo, I have setup a few virtual hosts to test and the html files work fine.
I get this error from the log
"AH01071: Got error 'Primary script unknown"
For some reason, apache seems not to recognise the php files in the virtual host directories. Strange.
Huh, this error means that you're running php-fpm and not as the common apache module.
If that's the case, you need to add the code you're using to call the php-fpm script in the main httpd.conf (ProxyMatch or SetHandler), into the vhost stanza too.
Huh, this error means that you're running php-fpm and not as the common apache module.
If that's the case, you need to add the code you're using to call the php-fpm script in the main httpd.conf (ProxyMatch or SetHandler), into the vhost stanza too.
Well ideally you should have each site having a separate PHP-FPM pool per vhost with permissions segregating the sites out for PHP-FPM... but you could put it down as 'server config' and then it should apply to all vhosts automatically I believe: https://httpd.apache.org/docs/2.4/mo...tml#sethandler
this works, must I add a new line to my httpd.conf for each vhost?
No, if you add it in the global httpd.conf i't available everywhere, so you don't need to add it in ever vhost configuration too.
BTW you could use a third party repo in order to install php-5.6 as a DSO for apache (e.g. https://webtatic.com/packages/php56/)
No, if you add it in the global httpd.conf i't available everywhere, so you don't need to add it in ever vhost configuration too.
BTW you could use a third party repo in order to install php-5.6 as a DSO for apache (e.g. https://webtatic.com/packages/php56/)
mod_php/DSO is horrible tho and should be avoided. It causes apache to consume memory and limits you to MPM-prefork or MPM-ITK, both of which have the performance of a drunken slug. PHP-FPM actually gives a significant performance improvement and doesn't bloat the size of every apache thread to elephant like proportions.
Last edited by r3sistance; 02-28-2017 at 03:26 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.