Can't access to amazon ec2 instance - php

I can't access to amazon ec2 instance using ssh terminal:
ssh -i new.pem ubuntu#<public-ip>
It says connection closed by <public ip>
and FileZilla stopped working and I am getting this error:
Error: Server unexpectedly closed network connection
Error: Could not connect to server
This all happened after I changed the server's /etc folder's permissions to 775 to update the php.ini file.
What happened?

Sounds like your instance may be hosed following the permission changes.
Take a look at this question: https://serverfault.com/questions/364677/why-is-chmod-r-777-destructive which describes a similar situation.
And a look at this potential resolution: https://serverfault.com/questions/234061/re-gaining-root-access-to-an-ec2-ebs-boot-image
Never had this happen to me so not personally used the recovery technique.
Good luck!

Related

PHP oci_connect() is working on terminal/Centos server but not on browser

I am getting error when I trying from browser.
Warning: oci_connect(): ORA-28759: failure to open file in
/var/www/myapp/abc.php on line 16
Fatal error: ORA-28759: failure to open file in /var/www/myapp/abc.php on
line 19
But when running same file from Server terminal as a root user > PHP abc.php that time oracle database output is coming.
I didn't understand why is running from terminal but not on browser.
I am using PHP7, Apache and Installed Oracle 19c home db.
I am using oci_connect to communication with oracle database from PHP code.
I think there is some permission issue to my httpd (apahce).
Please give suggestion.
Check that the web server process has access to all the Oracle client libraries and data files. Since you are using an Oracle home, make sure all the directories have 'other' access permissions set. Typically user home directories don't have this by default.
Since the app is running, some libraries are being loaded so maybe permissions are OK? Make sure you have the web server process environment variables the same as those used by your command shell to make sure the same set of Oracle client libraries are being used. (Do you also have Instant Client installed somewhere, or another Oracle home??).
The recent common causes of 'ORA-28759: failure to open file' are when Oracle cloud wallets are being used and the sqlnet.ora path to the wallet (the DIRECTORY=... bit) is not valid. ​Check the path is OK, or the Oracle Net configuration files are in the default location (and are readable). Note that with Instant Client 19.14 you can use 1-way TLS so wallets are not always needed, depending on your net configuration.
I doubt there is a problem with php.ini, since you are obviously able to call OCI8 functions. The php.ini file doesn't control behaviors of the Oracle Client libraries that are throwing the error.
Update your question with more details about how you are setting the environment and what Oracle configuration files are being used for connecting

phpsdk_deps returns fatal error on windows

To compile PHP 7.1.X on Windows I use steps written here:
https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
When I try to update dependencies with following command:
phpsdk_deps -u
I get following error:
D:\php-sdk2\php-sdk-binary-tools\phpdev\vc14\x64_71_2\php-7.1.15-src
$ phpsdk_deps -u
Fatal error: Uncaught SDK\Exception: Failed to fetch supported
branches
This is happening for almost two weeks now.
You're having network trouble.
If you open up the Config.php file at this line, you'll see that the Config tries to load the URI https://windows.php.net/downloads/php-sdk/deps/series/, and pick the correct txt file from there, in order to download the right dependencies. The exception you get means that this cannot be properly fetched.
The solution in my case was to use the company proxy (command line wasn't using it, so it cannot properly resolve & reach the above URL, and so the Config.php gets an empty response). How to do so might change depending on the network settings you use. In my case, I simply visited the URL above in Firefox (which is properly configured by the company), opened up the network pannel, get the IP of the website from there (which is actually the IP of the proxy Firefox was told to use by the company settings), and add the IP hostname entry in my host file (C:\Windows\System32\Drivers\etc\host) so it looks like 10.1.2.3 windows.php.net
Then I rerun the Config script, and boom, it managed to retrieve the txt files and the dependencies.
Another solution can be to retrieve all the dependencies listed in the txt file that corresponds to your setup, but it's a bit tedious...

Permission denied while trying to access localhost

In PHP 7.2 on a Centos 7 machine, I'm trying to access an Apache Jena Fuseki 3.6 SPARQL endpoint.
Fuseki runs on port 3030, the name of the dataset is ds and I can successfully run curl http://localhost:3030/ds - while being logged in on that system even with a user without any rights.
Everything seems fine so far.
However, when I try in a PHP script to do fopen("http://127.0.0.1:3030/ds","r"); or fopen("http://localhost:3030/ds","r"); I always end up with PHP Warning: fopen(http://localhost:3030/ds): failed to open stream: Permission denied.
Fetching a file from the WWW or even from the very same Apache server like fopen("http://localhost/mytest.html","r"); works though.
Are there any special permissions necessary for accessing a different localhost port? firewalld is deactivated, btw.
It turned out that SELinux is the cause of the problem, preventing Apache from doing outbound connections on other ports.
See here: http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/

How to run a Laravel application that was not created by me on my personal server

I need to alter some of the front-end features of a Laravel application that was not created by me. The application was created using Laravel and am not sure how to get it up and running so I can alter the front-end code. I was given a copy of the source files. I then put that source files in to my xampp/htdocs folder. I started Xampp, opened the folder in Gitbash and entered PHP artisan serve. The application does not appear to be running.
Is there something I am missing or doing wrong? Please take into consideration that I did not create this application, for your information, I do know how to create and run a Laravel app locally, but am wondering if the process is different if it was not created by me personally?
Thank you all for helping me out, I appreciate you personally and this community.
Here is the error I am receiving in Gitbash:
PHP Warning:
require(C:\xampp\htdocs\appoets\bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in C:\xampp\htdocs\appoets\bootstrap\autoload.php on line 17
Warning: require(C:\xampp\htdocs\appoets\bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
C:\xampp\htdocs\appoets\bootstrap\autoload.php on line 17
PHP Fatal error: require(): Failed opening required
'C:\xampp\htdocs\appoets\bootstrap/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\appoets\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\appoets\bootstrap/../vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\appoets\bootstrap\autoload.php on line 17
Please solved this for me. If you run into the same error. Have the correct file path open in Gitbash and then run "composer install"
After that was fixed another problem popped up. I went to load Laravel in my browser and it gave a general error message no error number or anything. To fix this go to your env.example file and rename it. .env then go to the terminal or your command line and run php artisan key:generate. After this hit save all and go refresh. All should be fixed!
The errors your getting are because you haven't installed your composer dependencies. Install them with composer before running the application:
composer install
Here's the old answer before that callstack was provided. I think it's still interesting background information for you, but not immediately relevant.
It looks like you're running two web servers so I suspect you're just
confused about where the application is running.
XAMPP ships with Apache. I'd expect that running it will spin up its
web server on port 80, the default port that web browsers use.
Therefore, if you're trying to get to the application at
http://localhost, you're hitting this webserver, which might have a
different (and not set up) application on it.
Running php artisan serve will start a second web server utilizing
PHP's built in web server. According to the documentation, the
default port that this command will use is 8000:
By default the HTTP-server will listen to port 8000. However if that
port is already in use or you wish to serve multiple applications this
way, you might want to specify what port to use. Just add the --port
argument:
Therefore, you can access the application without XAMPP though this
url: http://localhost:8000
Try both URLs.
Note that php artisan serve doesn't start up a MySQL server. You
will still need XAMPP to start the MySQL server if you're using a
database.
Checklist for your issue
1. composer update --no-scripts or composer install
2. php artisan key:generate
3. rename example.env to .env
4. Change database credentials, set debug mode! Change app url
4. php artisan migrate(make sure u have the database running in the server)
5. php artisan config:clear
6. you are good to go!

phpMyAdmin causing failed connections

I am running phpMyAdmin on an amazon EC2 ubuntu lamp stack, configured to use a remote RDS server.
I have run the sudo dpkg-reconfigure phpmyadmin configuration script, accessed RDS using the master username and master password (not rdsadmin but that set on initialisation), and can log into the phpMyAdmin console.
However, every refresh of the phpMyAdmin interface creates a new failed connection. In the logs I see:
2014-01-14 23:42:20 12879 [Warning] Access denied for user
'phpmyadmin'#'[IP address]' (using password: YES)
What is the best way to try and debug this?
SOLVED
For reference, when using EC2 with RDS and the phpmyadmin installation wizard above, the control user is set to use an unresolvable host, such as ip-[EC2 IP ADDRESS].eu-west-1.compute.internal. Simply changing the host to your actual EC2 IP address allows the connection to become valid and failed connections no longer occur.
This may be because you've configured a controluser in your config.inc.php file (naming the controluser 'phpmyadmin'), but that isn't actually a valid user on the server. If that's the case, you could resolve it by either removing that line from the configuration or creating the user using the script provided (normally in the "examples" folder, but who knows where it is in the Ubuntu file system).
Try grep phpmyadmin config.inc.php on the configuration file and see if anything interesting is found.
Though, come to think of it, normally Ubuntu handles that sort of thing for you, so it's possible you've got a larger misconfiguration going on here. I'd also try reconfiguring it (dpkg-reconfigure --plow phpmyadmin) and see if you can get any further.
Are there any error or warning messages displayed within phpMyAdmin?
Did you add the EC2 ip address to the RDS security group ?
Check this a similar link Using PHPMyAdmin to administer Amazon RDS
Thanks

Categories