我以前在Ubuntu/Apache主机上有这个网站,现在已经转移到Debian/Nginx主机上了。当我搬到Nginx时,似乎以前工作的形式不再工作
表单是如何工作的,它是托管在一个Wordpress网站,位于www.mycompany.com。然后,它将数据发送到一个控制器,该控制器托管在同一台服务器上,但使用虚拟主机site1.mycompany.com。
当我发布数据时,表单只是挂起,查看控制台显示
POST https://site1.mycompany.com/request_form/submit 500 (Internal Server Error)
CodeIgniter控制器名为request_form,提交函数像这样开始(给你一个概念)
public function submit()
{
$return = array('error' => false, 'msg' => '', 'error_data' => array());
$validation_rules = array();
//$this->form_validation->set_rules('serial_no', 'Outdoor Serial No', 'required');
$this->form_validation->set_rules('enquiry_type', 'Enquiry Type', 'required');
$this->form_validation->set_rules('txt_email', 'Email', 'required');
if(!empty($this->input->post('txt_email')))
{
$this->form_validation->set_rules('txt_email','email','valid_email|callback_email_exist');
}
$this->form_validation->set_rules('txt_phone', 'Phone', 'required');
$this->form_validation->set_rules('txt_address', 'Address', 'required|callback_check_address_for_state');
$this->form_validation->set_message('check_address_for_state','Address is not valid!');
我的Nginx配置site1.mycompany.com是
server {
server_name site1.mycompany.com;
root /var/www/html/site1.mycompany.com;
index index.php index.html index.htm;
autoindex on;
client_max_body_size 50M;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ /index.php;
}
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
在/var/logs/nginx和CodeIgniter下都没有错误日志,即使启用了完整的日志记录。我已经尝试了各种更改Nginx配置,但无济于事。
试试这些基本设置。(为了方便调试,只需在主控制器中添加echo "works"; die;
并检查)
在Ngnix
server {
server_name site1.mycompany.com;
root /var/www/html/site1.mycompany.com;
index index.html index.php;
# set expiration of assets to MAX for caching
location ~* .(ico|css|js|gif|jpe?g|png)(?[0-9]+)?$ {
expires max;
log_not_found off;
}
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~* .php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
}
}
在config . php
$config['base_url'] = "http://site1.mycompany.com/";
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";