#重新nginx 配置:
cat << EOF > /usr/local/nginx/conf/nginx.conf
error_log /var/log/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_tokens off;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php\$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
}
EOF
#创建PHP测试文件:
echo "<?php echo phpinfo(); ?>" >/usr/local/nginx/html/index.php
#备份index.html:
mv /usr/local/nginx/html/index.html{,.bak}
#启动nginx:
service nginx start
#将nginx 写入随机启动:
chkconfig --add nginx && chkconfig nginx on
#开启防火墙的80端口
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
#保存防火墙配置
service iptables save
#重启防火墙:
service iptables restart
#设置nginx、mysql 及php 的环境变量:
echo "PATH=$PATH:/usr/local/php/bin:/usr/local/nginx/sbin:/usr/local/mysql/bin:/usr/local/php/sbin" >> /etc/profile
#刷新环境变量配置,使其立即生效:
source /etc/profile
##======================================= 安装php 加速器 xcache 3.2.0 ====================================
#官方地址:
cd $SoftDir && wget -q
#解压
tar zxf xcache-3.2.0.tar.gz
#执行phpize,生成xcache 的configure 文件
cd ./xcache-3.2.0 && /usr/local/php/bin/phpize --clean && /usr/local/php/bin/phpize
#配置编译参数:
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config >> $LOG_INS 2>&1
#编译及安装
MAKE && MAKE_INS
#将xcache 结合php
echo "extemsiobn_dir='/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/'" >> /usr/local/php/etc/php.ini
echo "extension=xcache.so" >> /usr/local/php/etc/php.ini
#检测php 是否有误:
/usr/local/php/sbin/php-fpm -t
#重启php-fpm:
service php-fpm restart
Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置