Adding a variable to httpd.conf file stops Apache from working - php

In my efforts to solve an OCI8 error, I've been led to believe it is the result of an improperly setup environment variable.
What I'm trying to do: Fix this apache environment headache, by adding variables to a certain file.
My actual problem is similar to this error from another StackOverflow user. To quote his answer to his problem:
Problem solved!
To put variables in Apache's Environment section you just have to add
them in /etc/sysconfig/apache2 file:
LD_LIBRARY_PATH=/path/to/oracle/lib.
Notably, the solution called for the modification of the file apache2.
However, I found no such apache2 file on my system.
What I've done so far:
I searched over the net, but the closest I could come up with is /etc/httpd/conf/httpd.conf file. Assuming the httpd.conf is apache2, according to this thread, I should add the variable to the end of the file, and it should work.
So I added export LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/xe/lib at the very end of the file.
And... apache won't even start anymore.
My system:
It's a Fedora 19 server, with Oracle 11g, PHP 5.5.4, Apache 2.4.6, and PEAR 1.9.4. In addition to this, I have the OCI8 plug-in for PHP downloaded and enabled, and have downloaded MDB2 and the MDB2_Driver_oci8.
Apache starts automatically when I boot up my system, though if for some reason I need to stop, restart, or check its status, the command I use is systemctl start httpd.service, if it means anything.
Thanks. I've been pulling my hair out on this problem.

A few things (hopefully an answer is somewhere inside)
First off, I wouldn't do this on Fedora. Fedora is the testbed for RedHat Enterprise/CentOS and it changes frequently. Even if this is just for your testing purposes, you'll find better support if you install CentOS 6 instead. The environment is virtually identical, but CentOS is better supported because so many people use it to run their servers.
Second, it sounds like you want to run the OCI8 connector (there's a reason I plugged CentOS 6). CentOS has many good repos like Remi. If you install CentOS 6 you can use his repository. This is important because this will save you a LOT of headaches down the road. Once you have his repo installed, you can do this
yum install php-oci8
And that should configure Apache to run your OCI8 extension. It's really that simple.

Related

How to fix apachetl not finding apache instance and stop the server?

I am currently running macOS High Sierra version 10.13.6.
I am trying to stop an apache server from running on my localhost port 8080. This is what I get when I load localhost:8080 in my browser: Apache / PHP server screenshot. From research and the help of others in:
How to kill Apache / PHP server running on local host port 8080? I believe that my apache installation is broken because when I run the command sudo /usr/sbin/apachectl stop, it says: cannot find specified service.
I do not ever recall installing apache or starting the server, but it could have something to do with postgres. Is there a way I can try to fix my installation so that I can find the apache instance and stop it when I run sudo /usr/sbin/apachectl stop? If it is not an installation error, I am open to hear other ideas.
The EnterpriseDB logo on the screenshot kind of hints that this is not a standard installation of Apache, but something bundled together with EnterpriseDB, and it seems to have its own control scripts.
If you are not using it and do not plan to use it in the future, the most sensible thing would be to uninstall it completely.
If you just want to stop it, try running sudo /Library/PostgreSQL/EnterpriseDB-ApachePHP/apache/bin/apachectl stop
But if you only stop it, most probably it will start again automatically after next reboot, so if you're not uninstalling it, you can at least disable it. Here's a post on SuperUser (which is where you should've asked this question instead of SO, btw) where it was discussed how to disable the PostgreSQL server.
AFAIK, Apache is started as a part of the whole thing, so it should get disabled together with it.
The post is a bit older but the steps should be very similar, if not the same (apart from the PostgreSQL version).
Hope this helps.

Code only works if I use the Xdebug extension

When I started my latest project I learned how to use the xdebug extension and I have been using it ever since. Now I am ready to spin up a server and go in to production with this project and my site doesn't fully work. The frontend pages seem to work, which are php based as well, but the backend endpoints that query the database and return some data to the frontend always are returning a 500 status code. So I attach xdebug and figure out how to run it remotely and the pages all start working without any code changes. I go in to the php.ini file and turn it back off and the pages continue to work. Since this is an AWS EC2 server, I delete the instance and create a new one running the same initialization scripts I wrote to install all the software and I get the exact same issue. The server doesn't work until I follow the xdebug install instructions and restart apache2. And like before even when I unattach the xdebug extension via the php.ini file, the code continues to work. Even after the system is rebooted it still continues to work so whatever is being fixed appears to be permanent.
What would building and attaching the xdebug extension, and restarting Apache2, do to the a LAMP stack that would make my code work, even after the extension has been turned off? My server is being built with scripts that run various apt-get install commands with no binaries provided by me as it all is community provided programs. Like clockwork it breaks every time I rebuild the machine until I apply the extension. I can automate that in to my build scripts if I have to, but it is driving me a bit nuts that I don't understand what is happening.
When the server sends a 500 error, normally you get an entry to the php_error.log. So first check this file. Maybe there is some difference in memory limits, max. post variables etc.
I would suggest you to try to find calls of any xdebug specific functions such as var_dump() or any prefixed by xdebug_ in your code:
https://xdebug.org/docs/all_functions
What would building and attaching the xdebug extension, and restarting Apache2, do to the a LAMP stack that would make my code work, even after the extension has been turned off?
Installing one piece of software can bring with it another. If you sudo apt install php-xdebug without php installed, it will install php.

Simultaneous operation of ruby on rails and php on the web server Apache

On a remote server running Debian and running a web service written in php5;
At the time of transition from php to ruby on rails, I would like to operate simultaneously on the Apache php applications and ruby on rails applications.
I know that it is possible to implement using passenger, but I'm having trouble installing it. So, in the terminal I'm doing:
passenger-install-apache2-module
During installation, the following messages:
1)WARNING: Apache doesn't seem to be compiled with the 'prefork',
'worker' or 'event' MPM
Phusion Passenger has only been tested on Apache with the 'prefork',
the 'worker' and the 'event' MPM.
Your Apache installation is compiled with
the 'itk' MPM. We recommend you to abort this installer and to
recompile Apache with either the
'prefork', the 'worker' or the 'event' MPM.
After: sudo apt-get install apache2-mpm-prefork - Apache stops working
If I continue the installation, the following problem arises:
2) Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module
/home/user/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so
PassengerRoot /home/user/.rvm/gems/ruby-2.1.3/gems/passenger-4.0.53
PassengerDefaultRuby /home/user/.rvm/gems/ruby-2.1.3/wrappers/ruby
But if I'll put these lines in the config file, php stops working.
Who can tell how to solve this problem?
[
Hmm., Difficulties arose.
sudo apt-get install libapache2-mod-passenger
worked well
But, I still don't understand how to configure apache for both php and ruby on rails.
Could you illustrate examples of settings for httpd,sites-avaliable,mods-avaliable;
For available anywhere on the hard disk Ruby applications;
I hope it does not go beyond this issue.
]
I am guessing that Apache breaks for you when you try to use the prefork MPM because you are using options specific to the ITK MPM without wrapping them in an IfModule. Since you've switched from ITK to prefork, those options are no longer valid. An example of such an option would be AssignUserID. You'd find complaints about unknown options in your error log if that is the case.
Is there a specific reason you're using the ITK MPM? It's not that well tested with Passenger, but it should work, as the Passenger Apache User Guide lists some hints specific to ITK.
About the LoadModule for Passenger: Where did you put those lines? Did you create e.g. an /etc/apache2/mods-available/passenger.load file that you can enable? Then the Passenger module would load before the PHP one ("pa" comes before "ph") and if that breaks that could potentially be the reason for your problem, though usually Apache won't start if it can't load a module.
Is there anything useful in the Apache error log, about not being able to load the PHP module, for example?
You could also consider using the prebuilt Passenger packages for Debian available from Phusion. I've had good results with them. The dependencies list apache2-mpm-itk, so I'm reasonably sure they should work.

Restart Specific Version of PHP/Apache?

I just installed PHP version 5.5 on my server (Centos 6 / Plesk 12) and changed the php version for one of my sites. I can see via a php info file that the site IS using the new PHP version, but I don't know how to start that VERSION of php. I made some changes to PHP5 ini file but when I restart apache, it restarts the old version (php 5.4) and not php5.5 ..sorry I am not the best at shell commands but does anyone know how to restart the NEW php version if i have multiple versions installed on the server? Thanks!
additional info- the changes that i made to the php5.5 ini file is loading the zend_extension opcache.so ..which is why i installed php 5.5 in the first place!
BONUS QUESTION: will zend opcache be effective running php 5.5 as fastcgi? I've heard that object cache modules are not compatible with fastcgi because it lets users run the application as their own user so the cache can not create x number of caches for each user..if that makes sense..lol
Thanks
Not sure if anyone is still following this but I also got stuck with this too. The solution I found to work was this:
Depending on what PHP versions you have setup with Plesk you need to run the following command:
service plesk-php{version}-fpm restart
For example:
service plesk-php54.fpm restart
or
service plesk-php56.fpm restart
In centos 7 the "service" command actually just calls another function so you end up calling:
/bin/systemctl restart plesk-php54-fpm.service
You can call that directly if you want but it is a few extra characters to type in.
With the above in mind you are now free to edit your php.ini files for each specific version you have enabled via Plesk. For those who don't know the ini files are usually located here:
/opt/plesk/php/{version}/etc/php.ini
Where {version} is 5.4, 5.5, 5.6, etc...
Hope this helps someone else.
In regards to your bonus question - sorry I'm not sure as I've not worked with that specifically.

Best PHP download to keep all my options open?

In the past, I used WAMPserver on windows to parse PHP for me. This is a pre-configured package, focussed on working with MySQL.
When I tried to run PostgreSQL, I got error messages that said that my version of PHP wasn't compiled to work with PostgreSQL.
So, I've recently uninstalled WAMP and every associated with it. I've downloaded Apache 2.2.11 with openSSL, installed as admin(you know, run the command prompt as administrator, cd to the directory where the download was done and have it executed, so the install was done as admin).
That's that. I now have Apache installed, "it works" shows up, so I'm that far.
Now I'm wondering, do I download the exe and install, or the zip, or something else.
What is the best thing to do to make sure that the PHP on my system can handle everything I can ever throw at it?
Also, PHP first, or MySQL/Postgre first.
And lastly, what about PEAR? I need PEAR installed, which isn't standard on Windows. I'm guessing the pear.bat file in the PHP downloads will do that for me?
EDIT: I see one close vote, yet no comment as to why. It makes me wonder how people who are so lazy and rude got to have somany points.
I would recommend downloading the zip package, as configuring php is not really that difficult, and it allows you to add features as needed.
As for whether first to install php or MySQL/PostgreSQL, - it does not really matter. You can install them in any order.
Your guess regarding PEAR is quite correct
i haven't used wamp before, so i can't comment on that
i do however use xampp which sounds very similar
in xampp if i want to enable postgres support i edit the php.ini file and uncomment the postgres section of the ini file, same with any of the extensions that i need
perhaps this might be an alternative you can try if you get stuck
There are many ways to setup a HTTP server/PHP/database machine. Sometimes the behaviour of your development setup will differ from the live server's.
I would recommend finding out the setup your web host is using, then getting a vmware appliance image that fits that as close as possible and get any additional software using it's package manager (which is easier that installing stuff on Windows).
Setup a file sharing link between the VM and the host, make sure you can view the VM's port 80 in a browser running in your host OS and you're set.

Categories