Centos中安装php环境与配置WWW服务器方法

作者:简简单单 2014-01-02

设定档位置:/etc/httpd/conf/httpd.conf
网页资料位置:/var/www/html
网页执行档位置:/var/www/cgi-bin
网页相关纪录档目录:/var/log/httpd/

安装软体

yum -y install httpd httpd-devel httpd-manual
yum -y install php-5 php-bcmath php-dba php-devel php-gd php-imap php-ldap php-mbstring php-mysql php-ncurses php-odbc php-pdo php-pear php-pgsql php-snmp php-soap php-xml php-xmlrpc mod_ssl

修改设定档

vi /etc/httpd/conf/httpd.conf

ServerAdmin root@localhost


UserDir disable 修改--> #UserDir disable


#UserDir public_html 修改--> UserDir www


DirectoryIndex index.html index.html.var 修改--> DirectoryIndex index.html index.htm index.php index.html.var


LanguagePriority zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN
AddDefaultCharset UTF-8 修改成--> #AddDefaultCharset UTF-8 或者 AddDefaultCharset none

service httpd restart

  
配置php环境


vi /etc/php.ini

max_execution_time = 300
default_charset = "utf8"
upload_max_filesize = 180M
post_max_size = 80M
register_globals = On
max_input_time = 600
memory_limit = 160M

vi /etc/httpd/conf.d/php.conf

DirectoryIndex index.php 修改 #DirectoryIndex index.php

 

测试php是否正常启用

echo "" > /var/www/html/test.php

http://localhost/test.php
 
限某网域可读取资料夹
vi /etc/httpd/conf/httpd.conf(格式如下)

Deny from all
Allow from IP
192.168.1.0/24
Options Indexes FollowSymLinks

Deny from all
Allow from 163.32.X.0/24 192.168.1.0/24
Options Indexes FollowSymLinks

重新启动httpd

service httpd restart
 
虚拟主机

    ServerAdmin user@kh.edu.tw

    DocumentRoot /home/user

    ServerName user.kh.edu.tw

    ErrorLog /var/log/httpd/pedagogy/user-error_log

    CustomLog /var/log/httpd/pedagogy/user-access_log common

    DirectoryIndex index.php index.htm index.html default.htm


 
伺服器更改预设字码
伺服器更改为Big5(比较通用111com.net)

vi /etc/sysconfig/i18n

LANG="zh_TW.Big5"
SUPPORTED="zh_TW.Big5:zh_TW.UTF-8:zh_TW:zh:en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"

 或下指令

export LANG=zh_TW.Big5

伺服器更改为UTF-8

vi /etc/sysconfig/i18n

LANG="zh_TW.UTF-8"
#LANG="zh_TW.Big5"
SUPPORTED="zh_TW.UTF-8:zh_TW.Big5:zh_TW:zh:en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"

相关文章

精彩推荐