nginx+php+composer+git+域名配置+项目访问

本文作者: 架构师刘涛?


—————————————— epel仓库安装
epel是yum的软件源,里面包含了许多基本源里没有的软件
#默认的yum源无法升级PHP,需要添加第三方yum源,我们选择webtatic库
centos6 rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
#epel安装 yum install epel-release

—————————————— yum安装nginx
#nginx安装前需要先安装epel仓库
#nginx安装 yum install nginx

—————————————— nginx相关
#nginx版本 nginx -v
#测试配置文件 nginx -t
#设置服务开机启动 chkconfig nginx on

#nginx状态 service nginx status
#nginx启动 service nginx start
#nginx停止 service nginx stop
#nginx重启 service nginx reload

—————————————— nginx配置域名
#查找nginx.conf文件路径 find / | grep nginx.conf
/etc/nginx/nginx.conf
/etc/nginx/conf.d

#目录 /etc/nginx/conf.d/
#项目配置 project.conf

#vmware linux共享目录:/mnt/hgfs/projects

—————————————— project.conf
server {
listen 80;
server_name project.com;
root /mnt/hgfs/projects/project;

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi.conf;
}
}

—————————————— yum安装php
CentOs 6.x 的RPM源中php最高7.1
#PHP5.5安装 yum install php55w.x86_64 php55w-fpm.x86_64 php55w-mysql.x86_64 php55w-gd.x86_64 libjpeg* php55w-ldap.x86_64 php55w-odbc.x86_64 php55w-pear.noarch php55w-xml.x86_64 php55w-xmlrpc.x86_64 php55w-mbstring.x86_64 php55w-bcmath.x86_64 php-mhash
#其他php版本安装 如果想安装php5.6版本,将上面的php55w替换为php56w
#删除PHP相关安装包 yum remove php*
#php 7.0/7.1/7.2 分别表示为 70w/71w/72w
#PHP7.1安装 yum install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-fpm php71w-gd php71w-mbstring php71w-mysqlnd php71w-opcache php71w-pdo php71w-xml php71w-ldap php71w-mcrypt

—————————————— php相关
#php版本 php -v
#查看状态 service php-fpm status
#启动php service php-fpm start
#重启php service php-fpm restart
#设置服务开机启动 chkconfig php-fpm on

—————————————— 安装composer
#下载composer curl -sS https://getcomposer.org/installer | php
#移动composer到环境下可执行 mv composer.phar /usr/local/bin/composer
#合并 curl -sS https://getcomposer.org/installer | php;mv composer.phar /usr/local/bin/composer
#查看composer版本 composer -v

—————————————— git安装及配置
#安装git yum install git

#生成公钥私钥 ssh-keygen -t rsa -C "git@git.project.com"
/root/.ssh/id_rsa
/root/.ssh/id_rsa.pub

#git配置user.name user.email
git config --global user.name "liutao";git config --global user.email git.project.com

#clone项目 git clone 项目git

—————————————— 关闭selinux服务
#查看selinux运行状态
1) getenforce
2) /usr/sbin/sestatus -v //SELinux status:enabled 为开启状态
#关闭selinux 修改/etc/selinux/config 文件,SELINUX=enforcing改为SELINUX=disabled,重启

—————————————— 关闭防火墙(每次开机都要执行关闭)
#查看防火墙状态 /etc/init.d/iptables status
#关闭防火墙 /etc/init.d/iptables stop

—————————————— 域名访问
project.com

—————————————— 

问问群二戊二醛为


tags: PHP,Nginx,Git