简体   繁体   English

在EC2实例中运行PHP文件

[英]Run a PHP file in an EC2 instance

I created an EC2 instance and use the command line interface to connect to it. 我创建了一个EC2实例,并使用命令行界面连接到它。

I created a HTML page in the /var/www/html for testing purpose. 我在/ var / www / html中创建了一个HTML页面用于测试。 When I enter my public DNS (taken from my ec2 AWS console) in the Browser, my HTML content is successfully displayed. 当我在浏览器中输入我的公共DNS(从ec2 AWS控制台获取)时,我的HTML内容已成功显示。

I would like to host a PHP file in the EC2 instance which I want to run from java code. 我想在EC2实例中托管一个PHP文件,该实例要从Java代码运行。 The PHP file is in the location "/opt/app/current". PHP文件位于“ / opt / app / current”位置。

When I enter the public DNS, it successfully displays the HTML page, but the PHP code is not present there nor has it run and updated my database. 当我输入公共DNS时,它将成功显示HTML页面,但是那里没有PHP代码,也没有运行和更新我的数据库。

I am not sure if I am missing any steps. 我不确定是否缺少任何步骤。

您需要将httpd服务的主要配置文件上的文档根目录从/ var / www / html更改为/ opt / app / current(/etc/httpd/conf/httpd.conf-对于Amazon Linux,Redhat,Centos)

Which server are you using? 您正在使用哪个服务器? seems it is Apache first try to check if you Apache configuration is ok 看来这是Apache首先尝试检查您的Apache配置是否正常

https://www.maketecheasier.com/configure-apache-php-linux-server/ https://www.maketecheasier.com/configure-apache-php-linux-server/

You can easily validate you config by using 您可以使用以下方法轻松验证您的配置

apachectl configtest

apachectl -t

or even better: 甚至更好:

apachectl -t -D DUMP_VHOSTS

After that you should be able to understand what is wrong, algo you need to check your apache logs probably there you can found more details 之后,您应该能够了解问题所在,算法您需要检查apache日志,也许在那里您可以找到更多详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM