Ubuntu安装NGINX+PHP

Wesley13
• 阅读 1028

#禁止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

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
Ubuntu更换snap国内镜像源
1.1进入apt的源文件列表所在文件夹   cd/etc/apt 1.2 备份sources.list源文件   sudocpsources.listsources.list\_back 1.3 进入阿里云镜像站,找到ubuntu的镜像列表    https://developer.aliyun.com/
Wesley13 Wesley13
3年前
ubuntu ftp服务
aptgetinstallvsftpdaptgetupdatevi/etc/apt/sources.listvim /etc/vsftpd.confservicevsftpdrestart\
Stella981 Stella981
3年前
N1 armbian5.77 安装配置 cups打印机共享
修改源:vi/etc/apt/sources.listdebhttps://mirrors.ustc.edu.cn/debian/stretchmaincontribnonfreedebsrchttps://mirrors.ustc.edu.cn/debian/stretchmaincont
Wesley13 Wesley13
3年前
ubuntu 16.04 跑 docker
Ubuntu的软件源配置文件是 /etc/apt/sources.list换国内的,不然会疯。下面是清华大学滴:默认注释了源码镜像以提高aptupdate速度,如有需要可自行取消注释debhttps://mirrors.tuna.tsinghua.edu.cn/ubuntu/xenialmainrestric
Wesley13 Wesley13
3年前
Ubuntu14.04 desktop使用网易163镜像源
修改/etc/apt/sources.listdebhttp://mirrors.163.com/ubuntu/trustymainrestricteduniversemultiversedebhttp://mirrors.163.com/ubuntu/trustysecuritymainrestricte
Stella981 Stella981
3年前
Proxmox虚拟化配置国内源
PROXMOX6.0国内源设置与升级vi/etc/apt/sources.list.d/pveenterprise.listdebhttp://download.proxmox.wiki/debian/pvebusterpvenosubscriptionvi/etc/apt/source
Stella981 Stella981
3年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Wesley13 Wesley13
3年前
Ubuntu apt更换为阿里源
apt源配置在/etc/apt/sources.list,首先备份一下:cd/etc/apt/cpsources.listsources.list.bak然后修改sources.list为:debhttp://mirrors.aliyun.com/ubuntu/xenialmainrest
Wesley13 Wesley13
3年前
Ubuntu16.04安装docker
1.更换镜像(1)备份原来的源sudocp/etc/apt/sources.list/etc/apt/sources.list.bakcup(2)编辑sources.listssudovim/etc/apt.sources.list添加如下内容:debhttp://mirrors.aliyun.com/ubuntu