#禁止IP6协议
vi /etc/modprobe.d/blacklist.conf
#底部追加
blacklist ipv6
#修改软件仓库源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
vi /etc/apt/sources.list
#Ubuntu 14.04 阿里云仓库配置 输入如下内容
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://ppa.launchpad.net/ondrej/nginx/ubuntu trusty main
deb-src http://ppa.launchpad.net/ondrej/nginx/ubuntu trusty main
deb http://ppa.launchpad.net/ondrej/php/ubuntu trusty main
deb-src http://ppa.launchpad.net/ondrej/php/ubuntu trusty main
deb http://ppa.launchpad.net/ondrej/mysql-5.7/ubuntu trusty main
deb-src http://ppa.launchpad.net/ondrej/mysql-5.7/ubuntu trusty main
deb http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty main
deb-src http://ppa.launchpad.net/chris-lea/redis-server/ubuntu trusty main
#修改软件仓库源权限
chmod 644 /etc/apt/sources.list
chown root:root /etc/apt/sources.list
#更新源
apt-get update
#如提示信任问题,则需安装公钥
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B9316A7BC7917B12
apt-get update
#更新系统
apt-get upgrade && apt-get clean && apt-get autoclean
#安装环境
apt-get install vim make p7zip-full ncftp nginx php5-fpm php5-curl php5-imagick php5-gd php5-mcrypt php5-odbc php5-mysql php5-sqlite php5-mssql php5-redis php5-ldap php5-imap php5-mcrypt php5-xsl
#独立数据库服务器,遂未安装数据库,需要请加 mysql-server-5.6 mysql-client-5.6
#系统配置
修改文件 /etc/profile
最后加入 ulimit -SHn 65535
#修改PHP配置文件 /etc/php5/fpm/php.ini
sys_temp_dir = "/tmp";设置系统临时目录
upload_tmp_dir = "/tmp";设置PHP上传文件临时目录
session.save_path = "/tmp";设置SESSION保存目录
error_log = "/home/logs/phperror.log";记录PHP运行错误
log_errors_max_len = 102400;加大错误日志文件的尺寸
memory_limit = 384M;加大PHP内存限制,防止生成静态等大型操作内存不够
short_open_tag = On;启用开放标签,部分程序模板需要简写。
date.timezone = PRC;配置默认时区,避免部分程序时间紊乱。
#修改php-fpm配置/etc/php5/fpm/pool.d/www.conf
listen = /dev/shm/php5-fpm.sock ;网传这个目录性能比较好
listen.mode = 0660
pm.max_children = 192
pm.start_servers = 12
pm.min_spare_servers = 8
pm.max_spare_servers = 96
pm.max_requests = 1024
#修改NGINX配置文件
pid /run/nginx.pid;
user www-data www-data;
worker_processes auto;
#worker_cpu_affinity auto;
worker_rlimit_nofile 32768;
events {
use epoll;
worker_connections 8192;
multi_accept on;
}
http {
server_tokens off;
sendfile on;
autoindex off;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 120;#长连接超时时间,单位是秒
reset_timedout_connection on;#关闭不响应的客户端连接
send_timeout 15;#发送数据超时
include mime.types;
default_type application/octet-stream;
gzip on;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1k;
gzip_comp_level 5;
gzip_types text/plain text/html text/css text/xml text/plain application/json application/javascript;
access_log /home/logs/access.log;#指定默认日志文件路径
error_log /home/logs/error.log error;#指定默认错误日志文件路径
server {
listen 80 default_server;
server_name _;
root /home/wwwroot/default/;
index default.html index.php index.html index.htm;
location ~ \.php$ {
include fastcgi.conf;
}
}
include /etc/nginx/sites-enabled/*.vhost;
}
#修改fastcgi配置文件
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_pass unix:/dev/shm/php5-fpm.sock;
#创建环境目录
mkdir /home/backup
mkdir /home/logs
mkdir /home/wwwroot
mkdir /home/wwwroot/default
#创建环境测试文件 /home/wwwroot/default/index.php