centos 安装apache2.2+mysql+php

来源:互联网 发布:少儿编程 童程童美 编辑:程序博客网 时间:2024/05/17 21:49

1.yum install httpd httpd-devel 


2.yum install mysql mysql-server mysql-devel 


设置远程登录:GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; 


3.yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml 


apache配置:

vi /etc/httpd/conf/httpd.conf 编辑文件

   Options Indexes FollowSymLinks        在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI)

   #AddHandler cgi-script .cgi        在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)

   AllowOverride None          在338行 修改为:AllowOverride All (允许.htaccess)

   AddDefaultCharset UTF-8         在759行 修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)

 Options Indexes MultiViews          找到这一行,将“Indexes”删除 ,变为此状态 Options MultiViews (不在浏览器上显示树状目录结构)

   DirectoryIndex index.html index.html.var          在 402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var  (设置默认首页文件,增加index.php)

   KeepAlive Off           在76行 修改为:KeepAlive On (允许程序性联机)

   MaxKeepAliveRequests 100          在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)  

:wq!  #保存退出

   /etc/init.d/httpd restart 重启

   DocumentRoot "/var/www/html"  修改为你的目录   "/data0/www/xxxxxxxxx"  (这个目录就是挂载的数据盘)

   rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html    #删除默认测试页

 

Apache的日志文件   
    ErrorLog  /etc/httpd/logs/error_log   (php的错误日志也输出到这里)
    CustomLog  /etc/httpd/logs/access_log combined


php配置

-----------------------------------------------------

vi  /etc/php.ini   #编辑

date.timezone = PRC     #在946行 把前面的分号去掉,改为date.timezone = PRC

magic_quotes_gpc = On   #在745行 打开magic_quotes_gpc来防止SQL注入  (php5.4开始不支持magic_quotes_gpc(防SQL流入))

log_errors = On         #记录错误日志

 

:wq!  #保存退出

/etc/init.d/httpd restart   #重启Apche , php

0 0
原创粉丝点击