I've struggling a lot trying to get solr working. I've read the official docs and tutorials, tried them out but still couldn't figure out how to get started. I took to randomly test out blogs which resulted in crashing of my ubuntu OS.
So, I'm framing a question here, outlining every possible doubt of mine and everything I've tried out.
I downloaded the apache solr 4.3.0 from here: http://lucene.apache.org/solr/
Next, I unzip the file [path: /home/ps/solr] and inside there is an example directory containing the schema.xml, solrconfig.xml and other important files.
Next, I choose the official solr php client and installed it. [Link: http://docs.php.net/manual/en/book.solr.php]. It requires a PECL extension which I forked from here [https://github.com/lukaszkujawa/php-pecl-solr] as there are some issues with running it with solr4.x. The path of php-pecl-solr is home/ps/php-pecl-solr. I followed this blog (http://systemsarchitect.net/integrate-php-application-with-solr-search-engine/) to install the PECL extension.
After all this, I tried writing down a test script (http://dpaste.com/1173282/) as in the blog, and running it: it displayed nothing. The page wasn't opening. The file's path was var/www/testsolr/index.php
My doubts:
Why isn't the page opening? What am I doing wrong here?
How to connect the example directory of solr with this php-pecl-solr extension?
I'm just a beginner with these things and would be happy if someone helps me out.
Solr comes with logging code, but it's not enabled by default.
From the example directory, rather than "java -jar start.jar", add a system property on the command line that imports the logging.properties file. If you launch start.jar from the example directory, use:
java -Djava.util.logging.config.file=etc/logging.properties -jar start.jar
your log will be in example/logs/solr.log.
I recommend that you not use PHP until you've got solr properly configured and running reliably, after you've been able to import your data and you can do queries from your browser the return the expected results.
I'm new to solr too. I've been beating my head against it for two weeks, but I'm starting to have some success.
Your log is likely to contain lots of Java exception stack traces. These are almost always the result of errors in your configuration files, but the log is very unhelpful in that it doesn't tell you what line of which file has the error! Thus I've had to beg Google for insight, which is sometimes found here at Stackoverflow.
Make sure you have your JDBC connector installed. It will be a free download for whichever database server your using, but is not bundled with solr.
First you need to make sure you have Solr running on your server. The simplest way to this is to run java -jar start.jar from the example directory under /home/ps/solr. This will startup Solr using Jetty at the url of http://127.0.0.1:8983/solr.
You will need to modify your test.php file and put the full url http://127.0.0.1:8983/solr for your hostname item in your $options array.
Related
So I'm in the process of getting into a project that already exists, including hosting it.
I've got all the source code (have yet to transfer the files from the old hosting)
The webpage is hosted on a Plesk Onyx 17.8.11, OS Ubuntu 18.04.3 LTS.
Most of the website runs like a charm, sans anything that includes loading files and the generating of pdfs (maybe other stuff I haven't found yet).
When I want to generate a pdf (using a queue worker), I get the error sh: 1: wkhtmltopdf: not found in my laravel.log, which points to the line of code that catches any errors thrown in the pdf-generation.
wkhtmltopdf is installed via composer (and also in the composer.json), both in the project and globally. I already searched the web, and found the hint to use the binary option. However, since the codebase is not exactly small, and I know it runs fine on another host, I don't want to change all instances of generatePdf() to include the option. Because it runs on another server, it feels like there's some configuration I'm getting wrong.
Thanks in advance!
Update: I had to install wkhtmltopdf with patched qt, as described here, now it works like a charm.
Using the hint from #cOle2, I got wkhtmltopdf via apt-get instead of composer. This made wkhtmltopdf usable from anywhere and lead me to another error: The switch --footer-html, is not support using unpatched qt, and will be ignored.qt.qpa.screen: QXcbConnection: Could not connect to display\nCould not connect to any X display. This error lead me here, and reinstalling wkhtmltopdf as described there fixed the problem.
tl;dr Install wkhtmltopdf as binary WITH patched qt.
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.
Introduction
Before getting started with the actual question, I’d like to make a notice of being an extreme beginner to the world of web sockets using PHP. As a matter of fact, I’m still trying to grasp the very basics of it. I do however have lots of experience with sockets overall, from languages such as Java.
Upon doing my research, I stumbled upon the tutorial from PHP builder, whereas I think myself to having learned how to set socket connections up using this simple library.
Problem
Unto the problem we go. For a development server, I have chosen to go with XAMPP—it’ss sort of stayed with me from my Windows days, many years ago. At this very moment, I am using the terminal UI for XAMPP in Ubuntu—meaning, I launch the XAMPP server and then do a killall should I ever wish to close it.
In the tutorial mentioned above, you enter this information into your PHP document where you keep your server socket:
$server = new Server('192.168.0.8', '8000');
The Server class being a class extended by the WebSocketServer provided in the aforementioned library. You’re then supposed to run the PHP server socket using (with the dollar sign symbolizing terminal input):
$ php -q serversocket.php
It was suggested somewhere else on Stackoverflow that you run the server socket with the -f flag instead, but both of them—instead of starting the server socket—prints out the file contents in the terminal.
The PHP I’m using (to attempt running the server socket) is the one you get from running (on Ubuntu):
$ sudo apt-get install php
I’d assume this to be the regular version of PHP.
I’m honestly probably just being a huge moron, but truly do need help to solve this problem. Have I missed something?
The problem that was occurring at the time was the PHP code being displayed as raw data in the terminal whenever run. I was using short opening tags at the time <? and did have them enabled in the configuration.
I did however, resolve the issue, by rewriting the code to use the full opening PHP tags <?php. Perhaps there was more things to configure, maybe the version of PHP I was using was broken. Who knows?
I was wondering how to link a SQL database on my PHP code.
I am using a database on my local server that I set up and I have already created a database, I tried writing a PHP script with ++notepad, but when I clicked on the script, it opened the browser and displayed a blank page. What am I doing wrong? I created my databases using phpMyAdmin.
You need to be running a web server locally which supports PHP (like Apache). It it the web server which does the PHP processing. At the same time you will have to run a MySQL (or any other) database engine too, so your PHP code can connect and query it. (I'm assuming you've already installed PHP.)
I would recommend you install XAMPP which includes Apache, PHP, MySQL and a bunch of other stuff. It one of "Apache friends". Once you install XAMPP you would have a folder htdocs in the xampp folder. Create a folder for you project myproject and place your PHP script script.php in there. Now if MySQL and Apache are running following should behave as you expect.
http://127.0.0.1/myproject/script.php
For the tutorial, to begin with you can use W3Schools. Brief and to the point. They have both a PHP tutorial and a SQL tutorial.
This is a very good book to start with:
PHP and MySQL
Web Development
Luke Welling and Laura Thomson
You have to play with php/sql code practically. Only reading cant help!
go for w3shools as mentioned above :)
start with simple code and then go to the complexity. all the best.. :)
There are multiple ways on how to do that.
One of the most modern ways to do that, is to use PDO to connect to the DB with PHP.
To run PHP on your PC(which i assume is your workstation), you need the supporting software for it, for php to run you need the PHP software installed, and likewise if you want to run the server software you need apache, however you can go for a single install package which will install almost everything for you to run your php script, download and install the wamp.
to install wamp which stands for (windows, apache, mysql, PHP) if you are running windows, and lamp for linux or mamp for mac, all of which are free softwares, you can download wamp from the following link. http://www.wampserver.com/en/download.php that is the first step which you need to do.
step 2: once wamp is installed the default directory of installation is C:/wamp (i reccomend do not change the location of the installation), you need to start the wamp server by just opening or double clicking the software which you just installed.
step3: navigate to the default directory where you should be storing your PHP files and that is C:/wamp/www note that you should be keeping all your PHP files here apart from this location if you store it anywhere else it wont simply run at all, and that it should and must have the .php extension.
step4: create or save the php files in this location(c:/wamp/www) i for example will assume you have created a file test.php in the www folder. now to access this file open your web browser and type http://localhost/test.php there you go, you will have the access to your PHP file (Note: PHP files cannot be run by simply double clicking the file, you have to follow this procedure in order to run the PHP files)
step5: open the test.php in any of your text editor like notepad, or i recommend use an IDE (Netbeans is free and worth a try), and write your code in the following format.
<?php
your PHP code should go here.
?>
when i started writing the code i started by following a nice tutorial which i found in zend.com, it has one of the best examples, and moreover the tutorial is meant for the beginners. hope this helps you..
http://devzone.zend.com/tag/PHP101
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.