一般范围previous questionPOST方法返回405方法不被允许的Apache生产服务器上 - Symfony3项目在这里描述
我设法让该项目在本地工作得很好,之后我发布的项目到我的雇主的生产服务器和后它是活的一些配置。但是,当我在本地执行POST方法时,我得到了“405方法不允许”。
- 这是路由问题吗?
- 它是一个配置问题?
- 这是一个权限问题吗?
- 还有别的吗?
配置信息是很大,我不知道这将是一个安全风险,如果我张贴在这里,所以请让我,你需要知道
我会发布什么,我觉得是OK的分享:
文件:/etc/apache2/mods-available/userdir.conf
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
<Directory /var/www/html/pdf/web>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
文件:/etc/apache2/sites-available/000-default.conf
<VirtualHost ******:80>
ServerName ******
DocumentRoot /var/www/html/pdf/web
<Directory /var/www/html/pdf/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =*******
RewriteRule^https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
文件中:/ etc/apache2的/启用的站点 -/000默认-LE-SSL的.conf
<IfModule mod_ssl.c>
<VirtualHost *****:443>
ServerName *****
DocumentRoot /var/www/html/pdf/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile ********************
SSLCertificateKeyFile *****************
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
从phpinfo()函数:
- 系统 Linux的uvn-243-1.tll07.zonevs.eu 4.4.0-042stab123.9#1 SMP星期四06月29日13时01分59秒MSK 2017 x86_64的
- 服务器API Apache 2.0的处理程序
- Apache版本 Apache/2.4。18(Ubuntu的)
- 加载的模块芯mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias中mod_auth_basic mod_authn_core mod_authn_file模块mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_deflate模块mod_dir mod_env mod_filter mod_mime prefork的mod_negotiation模块mod_php7 mod_rewrite的mod_setenvif mod_socache_shmcb mod_ssl的mod_status的
正如所解释由Symfony文档:现在/ web文件夹中的根文件夹
我的功能:
/**
* @Rest\Post("/mcPDF/")
*/
public function getDataAction(Request $request){
// Change the path to your jar file location
$jarfile = "~/java/mcpdf.jar";
// Change the path to your prefered destination where the output file will be created
$result = "~/pdf_output/output.pdf";
$form = $request->get('form');
$data = $request->get('data');
if(is_null($data) || $data == ""){
return new View('Data source not found', Response::HTTP_NO_CONTENT);
}elseif(is_null($form) || $form == ""){
return new View('Form source not found', Response::HTTP_NO_CONTENT);
}
$command = "java -jar $jarfile $form fill_form - output - < $data > $result";
$result = exec($command, $output);
// dump($result);
exit;
}
/**
* @Rest\Post("/mPDF/")
*/
public function createPDFAction(Request $request){
$source = $request->get('source');
if($source == ""){
return new View('No Data found', Response::HTTP_NO_CONTENT);
}
$mpdfService = $this->get('tfox.mpdfport');
$html = file_get_contents($source);
$mpdf = $mpdfService->getMpdf();
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
}
非常重要更新 成功地做了卷曲在服务器内部调用,它的工作!你认为它是一个POSTMAN问题吗?我使用的邮递员测试方法 卷曲电话:
同样适用于我。这应该是因为虚拟主机中从http到https配置的重定向。无法真正解释它的想法。 – sedigo