平臺: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