标签:
一,安装php7
1,创建php用户和用户组,并在github下载php7源码
#新建php用户和php组
# groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php
######从GitHub下载php7安装包
# wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zip
######开始解压php7包
# unzip -q php7-src-master.zip && cd php-src-master
#####安装编译php7时需要的依赖包
php-src-master]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
2,编译安装php
./buildconf
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl \
--with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd \
--with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath \
--enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring \
--enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear \
--with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir \
--enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo
make clean && make && make install
3选做步骤:执行make test命令进行测试
查看php扩展ls /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
需要确保至少存在 mysqli.so 、 pdo_mysql.so 这两个动态库文件
4,设置php配置文件
php-src-master]# cp php.ini-production /usr/local/php7/etc/php.ini
php-src-master]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
php-src-master]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
php-src-master]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
5, 添加php的环境变量
# echo -e ‘\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n‘ >> /etc/profile && source /etc/profile
6, 创建php相关进程日志目录
# mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
#######修改session的目录配置
# mkdir -p /var/lib/php/session
# chown -R nginx:nginx /var/lib/php
7,设置PHP开机启动以及测试配置文件是否正确
php-src-master]# chmod +x /etc/init.d/php-fpm
php-src-master]# chkconfig --add php-fpm
php-src-master]# chkconfig php-fpm on
#测试PHP的配置文件是否正确合法
sbin]# php-fpm -t
[03-May-2015 17:50:04] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
8, 配置opcache
vim /usr/local/php7/etc/php.ini
# 加入
zend_extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20141001/opcache.so
# 启动
/etc/init.d/php7-fpm start
# 查看PHP版本
/usr/local/php7/bin/php -v
结果:
PHP 7.0.0-dev (cli) (built: Mar 3 2015 10:02:26)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
vi php.ini
memory_limit = 256M
二,安装nginx
1,创建用户
groupadd nginx
useradd -r -g nginx -d /usr/local/nginx nginx
2,安装所需扩展
yum -y install zlib-devel pcre-devel openssl-devel
wget http://nginx.org/download/nginx-1.9.9.tar.gz
3,编译nginx
tar -zxvf nginx-1.9.9.tar.gz
源码安装nginx
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx\
--with-openssl=/usr/include/openssl --with-pcre --with-http_stub_status_module --with-http_gzip_static_module \
--with-http_ssl_module --with-http_stub_status_module \
--without-http_ssi_module --without-http_autoindex_module --without-http_uwsgi_module
make && make install
4,注册为系统服务
# /sbin/chkconfig --add nginx
# /sbin/chkconfig --level 345 nginx on
更改程序目录拥有者:
chown -R nginx:nginx /var/www/linda040/
nginx和php配置文件修改:
vi php.ini
extension=mysqli.so
extension=pdo_mysql.so
vi php-fpm.conf
pid = run/php-fpm.pid
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
vi /usr/local/php7/etc/php-fpm.d/www.conf
user = nginx
group = nginx
listen = /tmp/php-fpm.socket
listen.backlog = 1024
listen.owner = nginx
listen.group = nginx
listen.mode = 0666
pm = dynamic
pm.max_children = 256
pm.start_servers = 150
pm.min_spare_servers = 50
pm.max_spare_servers = 250
m.max_requests = 8000
slowlog = log/$pool.log.slow
request_slowlog_timeout = 1s
三,安装mariadb
先备份数据库
mysqldump --single-transaction --add-drop-database --master-data=2 -uroot -p123456 --databases linda030 linda_copyright > source.sql
在https://downloads.mariadb.org/mariadb/repositories/#mirror=neusoft&distro=CentOS在线生成mariadb仓库配置
cd /etc/yum.repos.d/
vi MariaDB.repo
# MariaDB 5.5 CentOS repository list - created 2016-01-18 02:46 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=http://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
然后
yum -y install MariaDB-server MariaDB-client
安装完毕
service mysql start
设置root用户密码
mysqladmin -u root password ‘123456‘
设置远程登录
mysql -uroot -p123456
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
flush privileges;
配置大小写不敏感
vi /etc/my.cnf.d/server.cnf
在[mysqld]下添加
lower_case_table_names=1
character_set_server=utf8
slow_query_log=on
slow_query_log_file=/var/lib/mysql/slow_query.log
long_query_time=1
service mysql restart
centos6.4下安装php7+nginx+mariadb环境
标签:
原文地址:http://www.cnblogs.com/huanxiyun/p/5168127.html