月度归档:2016年01月

centos6.5 安装git 最新版本

#安装git需要的库
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker

#删除自带的git
yum remove git

#切换到目录
cd /usr/src

#可以去看看需要的版本号
https://www.kernel.org/pub/software/scm/git/

#这里选择下载git2.7.0版本
wget https://www.kernel.org/pub/software/scm/git/git-2.7.0.tar.gz

#解压缩
tar -zxvf git-2.7.0.tar.gz

#切换到git-2.7.0目录
cd git-2.7.0

#开始验证
./configure

#编译安装
make prefix=/usr/local/git all
make prefix=/usr/local/git install
echo “export PATH=$PATH:/usr/local/git/bin” >> /etc/bashrc
source /etc/bashrc

#查看版本号
git –version

centos6.5 yum 安装php7,nginx1.8.1

#更新系统服务

yum -y update

#导入remi源

#64
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

#32
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

#资源库
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#创建nginx.repo源文件

touch /etc/yum.repos.d/nginx.repo

#打开源文件内容

vim /etc/yum.repos.d/nginx.repo

#编辑器源文件内容

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

 

#更新源

yum –enablerepo=remi -y update 

#安装服务 php70,mysql,nginx,php-fpm
yum -y –enablerepo=remi,remi-php70 install nginx php-fpm php-common

#安装PHP模块
yum -y –enablerepo=remi,remi-php70 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

#安装Mysql
yum -y install mysql mysql-server

#安装mysql扩展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

#创建fastcgi.conf
touch /etc/nginx/fastcgi.conf

#打开fastcgi.conf
vim /etc/nginx/fastcgi.conf

#编辑fastcgi.conf

if ($request_filename ~* (.*)\.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 403;
}
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 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;

# PHP only, required if PHP was built with –enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

#打开nginx.conf (ps:我的nginx是最新文档版本1.8.1)
vim /etc/nginx/nginx.conf

#编辑以下内容

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;

events
{
use epoll;
worker_connections 65535;
}

http
{
include /etc/nginx/mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

sendfile on;
tcp_nopush on;

keepalive_timeout 15;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable msie6;
#limit_zone crawler $binary_remote_addr 10m;
log_format ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
#access_log /var/log/nginx/access.log main;
include /etc/nginx/conf.d/*.conf;
}

#设置nginx 自启服务
/sbin/chkconfig –add nginx
/sbin/chkconfig nginx on

#nginx 启动
/sbin/service nginx start

#设置php-fpm 自启服务
/sbin/chkconfig –add php-fpm
/sbin/chkconfig php-fpm on

#php-fpm 启动
/sbin/service php-fpm start

#添加mysql 自启服务
/sbin/chkconfig –add mysqld
/sbin/chkconfig mysqld on

#mysql 启动
/sbin/service mysqld start

#设置MYSQL密码
mysqladmin -u root password ‘new passwd’
#打开mysql
mysql -u root -p
#删除test数据库
DROP DATABASE test;
#删除匿名帐户
DELETE FROM mysql.user WHERE user =”;
#重载权限
FLUSH PRIVILEGES;

#设置一个独立的nginx 虚拟主机配置
cd /etc/nginx/conf.d

#创建一条zmq.conf
touch zmq.conf

#打开zmq.conf
vim zmq.conf

#编辑以下内容,对应请修改需要的ROOT目录

server {
listen 80;
server_name Domain name
index index.html index.htm index.php;
root you in path
location ~ .*\.(php|php5|php7)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
access_log you in url/you in name.log;
}

其余提示

php-fpm 需要配置相关的权限

nginx 执行的程序目录也需要配置权限