I have 2 AWS EC2 instance that are setup in the following :
- Webserver : all application codes (PHP) is hosted in here. In the future will scale up to more than one EC2 setup which will be placed under load balancing
- Dedicated Manticore EC2 : all manticore stuff is served and run here.
The problem is how will the webserver be able to run the indexer remotely? If it the webserver and manticore search is hosted in the same instance, it runs by using this php command :
shell_exec(‘sudo -umanticore indexer gen_search_index --rotate’);
I’ve already tried another PHP library called SSH2 but to no avail.
$connection = ssh2_connect(env(‘MANTICORE_INDEXER_HOST’), env(‘MANTICORE_INDEXER_PORT’));
ssh2_auth_password($connection, env(‘MANTICORE_HOST_USER’), env(‘MANTICORE_HOST_PASS’));
ssh2_exec($connection, ‘echo "’.env(‘MANTICORE_HOST_PASS’).’" |sudo -S -umanticore /usr/bin/indexer delta_job_search_index --rotate’)
The logging into the EC2 instance already works and I’ve tested this by writing a test file (with the right permissions). It’s the ‘sudo -umanticore indexer gen_search_index --rotate’ that is not working.