CentOS6.4下apache+php的简易搭建

2025-11-03 21:33:44

1、环境配置与安装准备:

CentOS6.4下apache+php的简易搭建

2、更新yum源;每天自动校准时间:

CentOS6.4下apache+php的简易搭建

3、组件安装:

CentOS6.4下apache+php的简易搭建

4、设置为开机自启:

CentOS6.4下apache+php的简易搭建

5、配置文件位置:

apache的配置文件是/etc/httpd/conf下

modules放在/usr/lib/httpd下

php的配置文件在/etc/php.d/下 和/etc/php.ini

php的modules放在/usr/lib/php/modules下

为mysql设置密码

拷贝配置文件

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

6、apache配置:

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

ServerTokens OS  在44行 修改为:ServerTokens Prod 

ServerSignature On  在536行 修改为:ServerSignature Off 

Options Indexes FollowSymLinks  在331行 修改为:Options Includes ExecCGI FollowSymLinks

#AddHandler cgi-script .cgi 在796行 修改为:AddHandler cgi-script .cgi .pl 

AllowOverride None  在338行 修改为:AllowOverride All 

AddDefaultCharset UTF-8 在759行 修改为:AddDefaultCharset GB2312 

Options Indexes MultiViews FollowSymLinks 在554行 修改为 Options MultiViews FollowSymLinks

DirectoryIndex index.html index.html.var 在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm

index.php Default.php index.html.var 

KeepAlive Off 在76行 修改为:KeepAlive On 

MaxKeepAliveRequests 100

7、php配置:

 /etc/php.ini #编辑

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

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname 

#在386行 。

expose_php = Off #在432行 

magic_quotes_gpc = On #在745行 

short_open_tag = ON #在229行

open_basedir = .:/tmp/

8、/etc/init.d/mysqld restart #重启MySql

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

CentOS6.4下apache+php的简易搭建

9、测试:

cd /var/www/html

vi index.php #输入下面内容

<?php

phpinfo();

?>

出现如下页面即完成。

CentOS6.4下apache+php的简易搭建

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢