笨不CentOS的7生成验证码,但在Windows
问题描述:
{
$this->load->helper('form');
$this->load->helper('captcha');
// Captcha configuration
$config = array(
'img_path' => 'captcha/',
'img_url' => base_url().'captcha/',
'img_width' => '150',
'img_height' => 50,
'word_length' => 3,
'font_size' => 35,
'pool' => '',
);
$captcha = create_captcha($config);
// Unset previous captcha and store new captcha word
$this->session->unset_userdata('captchaCode');
$this->session->set_userdata('captchaCode',$captcha['word']);
// Send captcha image to view
$data['captchaImg'] = $captcha['image'];
$this->load->view('Login', $data);
}
在Windows生成的验证码得非常好,在验证码文件夹中创建和图像显示在视图中。 问题是,我将我的Codeiniter网站移动到linux,CentOs7,我将www文件夹权限更改为777,并且所有者为apache,但仍未在captcha文件夹中创建图像,当然没有验证码图像出现在视图中。
ls -ld www ===> drwxrwxrwx. 4 apache apache 33 Jun 11 17:18 www
ls -ld www/html/CodeIgniter-3.1.3/captcha/ =======>
drwxrwxrwx. 2 apache apache 6 Jun 15 06:06 www/html/CodeIgniter-3.1.3/captcha/
答
我发现问题,CentOS在默认情况下启用了SELinux。我选择禁用SELinux的简单方法,现在一切正常。
sudo gedit /etc/sysconfig/selinux
变化
SELinux=enforcing to SELinux=disabled