平台:Centos 6.5 x86_64
1,安装源
rpm -Uvh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
2,更新并安装基本库和Apache
yum update -y
yum install -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel httpd
3,安装mysql
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yum install -y mysql-community-server
service mysqld start
mysql_secure_installation
mysql -u root -p 输入密码
创建要用的数据库。。。
4,安装php
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum install -y php55w php55w-common php55w-cli php55w-mysql php55w-gd php55w-fpm php55w-intl php55w-mcrpt php55w-mbstring php55w-mcrypt php55w-pdo php55w-pear php55w-soap php55w-tidy php55w-xml php55w-xmlrpc php55w-opcache php55w-devel
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini
sed -i 's/expose_php = On/expose_php = Off/g' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini
sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini
sed -i 's/disable_functions =.*/disable_functions =
passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php.ini
5,php加速模块
wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
tar -zxvf xcache-3.2.0.tar.gz
cd xcache-3.2.0
phpize --clean
phpize
./configure --enable-xcache
make && make install
cat xcache.ini >> /etc/php.ini
6,简单配置Apache
sed -i 's/MaxKeepAliveRequests 100/MaxKeepAliveRequests 1000/g' /etc/httpd/conf/httpd.conf (修改最大同时链接数)
sed -i 's/ServerTokens OS/ServerTokens Prod/g' /etc/httpd/conf/httpd.conf (在出现错误页的时候不显示服务器操做系统的名称)
sed -i 's/ServerSignature On/ServerSignature Off/g' /etc/httpd/conf/httpd.conf (在错误页中不显示Apache的版本)
sed -i 's/Options Indexes FollowSymLinks/Options Includes ExecCGI FollowSymLinks/g' /etc/httpd/conf/httpd.conf (容许服务器执行CGI及SSI,禁止列出目录)
sed -i 's/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi .pl/g' /etc/httpd/conf/httpd.conf (容许扩展名为.pl的CGI脚本运行)
sed -i 's/AddDefaultCharset UTF-8/AddDefaultCharset GB2312/g' /etc/httpd/conf/httpd.conf (将默认编码改成GB2312)
sed -i 's/ Options Indexes MultiViews FollowSymLinks/ Options MultiViews FollowSymLinks/g' /etc/httpd/conf/httpd.conf (不在浏览器上显示树状目录结构)
service httpd start
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html (删除默认测试页)
7,测试
echo "<?php phpinfo(); ?>" > /var/www/html/index.php
在浏览器输入http://yourserverip/,看到phpinfo信息就OK了,enjoy it !
php