php的安装
首先我们安装nginx
#0.安装ningx(可选
cd /disk1/tools
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install nginx -y
#查看cpu核数,如果不是8核的话,上传源nginx.conf,进行修改
nproc
#1.安装remi源
mkdir /disk1/tools
cd /disk1/tools
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -ih remi-release-6.rpm
#2.安装依赖
yum --enablerepo=remi -y install libxml2-devel bzip2-devel libpng-devel libmcrypt-devel libjpeg libjpeg-devel freetype freetype-devel openssl-devel libcurl-devel
yum --enablerepo=remi -y install gmp-devel libxslt-devel zlib zlib-devel curl curl-devel ncurses ncurses-devel gd-devel openssl-devel ImageMagick-devel
3.remi源安装php(gd+freetype)+imagick 如果没指定版本目前默认为5.4
yum --enablerepo=remi -y install php-imap php-ldap php-odbc php-pear
yum --enablerepo=remi -y install php php-devel php-mysql php-gd php-bcmath php-mbstring php-mcrypt php-mhash php-pdo php-pecl-imagick php-fpm
yum --enablerepo=remi install -y php-pecl-memcache php-pecl-redis
#yum --enablerepo=remi install -y php-pecl-memcache php-pecl-propro php-pecl-raphf php-cli php-magickwand
#yum --enablerepo=remi install -y php-pecl-mongo php-pecl-mongodb php-pecl-memcached php-pecl-raphf php-tidy php-pecl-yar
要是指定版本的话
可以指定版本,如php5.6
3.remi源安装php5.6(gd+freetype)+imagick
yum --enablerepo=remi,remi-php56 -y install php-imap php-ldap php-odbc php-pear
yum --enablerepo=remi,remi-php56 -y install php php-devel php-mysql php-gd php-bcmath php-mbstring php-mcrypt php-mhash php-pdo php-pecl-imagick php-fpm
yum --enablerepo=remi,remi-php56 install -y php-pecl-redis php-pecl-memcache
#yum --enablerepo=remi,remi-php56 install -y php-pecl-memcache php-pecl-propro php-pecl-raphf php-cli php-magickwand
#yum --enablerepo=remi,remi-php56 install -y php-pecl-mongo php-pecl-memcached php-pecl-raphf php-tidy php-pecl-yar
要是后期升级版本的话
直接yum update
#注:mongo区别
PHP Driver MongoDB 2.4 MongoDB 2.6 MongoDB 3.0 MongoDB 3.2
PHPLIB 1.0
+ mongodb-1.1 √ √ √ √
mongodb-1.1 √ √ √ √
mongodb-1.0 √ √ √
mongo-1.6 √ √ √
mongo-1.5 √ √
mongo-1.3 √
#php调试跟踪插件.5.4之后才有
#yum --enablerepo=remi install -y php-pecl-trace
phptrace --help
配置php-fpm
vi /etc/php-fpm.conf
修改一下日志路径
vi /etc/php-fpm.d/www.conf
修改
user = nginx
group = nginx
#3.报错解决:
yum --enablerepo=remi -y install php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-process php-fpm
报错:
Downloading Packages:
Running rpm_check_debug
ERROR with rpm_check_debug vs depsolve:
libmysqlclient.so.16()(64bit) is needed by postfix-2:2.6.6-6.el6_7.1.x86_64
libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by postfix-2:2.6.6-6.el6_7.1.x86_64
You could try running: rpm -Va --nofiles --nodigest
Your transaction was saved, rerun it with: yum load-transaction /tmp/yum_save_tx-2015-12-23-15-3670kk2L.yumtx
解决:
★★★★★如果mysql用的是yum安装,千万别因为yum安装不上php就卸载mysql-libs,会把mysql-server也卸载掉的!!!!!,
所以先确定mysql是否在用!!!
要不然你会死得很惨!!!!!!!!只能改为源安装!
[root@VM3 ~]# rpm -qa |grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
#卸载mysql rpm包,一定要先卸载
yum -y remove mysql-libs-5.1.7*
重新安装即可
nginx中配置pathinfo模式
因为用了thinkphp默认用的是是pathinfo模式,我配置的是LNMP,所以nginx要配置成pathinfo模式
如果nginx没有配置pathinfo模式用到路径方式会报404错误,如下图所示:
我现在把开发的包解压之后放在
[root@10-19-73-64 chunjie]# pwd /data/opt/chunjie [root@10-19-73-64 chunjie]# ll total 28 drwxr-xr-x 5 root root 4096 Jan 11 09:41 Application -rw-r--r-- 1 root root 434 Jan 28 2015 composer.json -rw-r--r-- 1 root root 1081 Jan 11 14:16 index.php drwxr-xr-x 2 root root 4096 Jan 12 11:33 logs drwxr-xr-x 4 root root 4096 Jan 11 09:42 Public -rw-r--r-- 1 root root 2717 Jan 28 2015 README.md drwxr-xr-x 8 root root 4096 Jan 11 09:40 ThinkPHP
在nginx配置文件进行修改如下:
[root@10-9-3-64 conf.d]# vim spring.conf server { listen 8081; server_name localhost; #charset koi8-r; access_log /data/opt/chunjie/logs/chunjie.access.log main; error_log /data/opt/chunjie/logs/chunjie.error.log; root /data/opt/chunjie; index index.php index.htm index.html; location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php{ fastcgi_pass 127.0.0.1:9000; set $script $uri; set $path_info ""; if ($uri ~ "^(.+?\.php)(/.+)$") { set $script $1; set $path_info $2; } fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $script; fastcgi_param PATH_INFO $path_info; include fastcgi_params; } } ~
同时要修改nginx.conf
include /etc/nginx/conf.d/*.conf;
进行以上修改之后,我们就重启一下nginx