以下安装过程是在Centos 系统下进行的。
一、PHP编译安装
1、下载php7(官网下载)。
wget http://cn2.php.net/distributions/php-7.2.13.tar.gz
2、解压安装文件
tar -xvf php-7.2.13.tar.gz
3、进入解压后的文件进行编译
cd ./php-7.2.13
5、安装php相关依赖包
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
6、编译配置(编译配置参数详解参考)
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
如果出现什么错误一般是因为依赖包未安装,依据提示安装相关依赖包就可以了。
7、编译安装
make //编译文件
make test //测试编译文件 只有make test 完全通过才能执行 make install进行安装
make install //编译安装
8、为php添加环境变量
打开/etc/profile文件 ,
vim /etc/profile
然后再文件尾部添加环境变量
PATH=$PATH:/usr/local/php/bin
export PATH
执行 source
使其立即生效
source /etc/profile
9、配置php
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
10、php-fpm相关命令
/etc/init.d/php-fpm start //启动
/etc/init.d/php-fpm stop //停止
/etc/init.d/php-fpm restart //重新启动
/etc/init.d/php-fpm reload //重载
/etc/init.d/php-fpm configtest //检查配置
/etc/init.d/php-fpm status //查看状态
php安装完毕。
二、nginx编译安装
1、下载nginx(官网下载)
wget http://nginx.org/download/nginx-1.10.3.tar.gz
2、解压安装文件
tar -zxvf nginx-1.10.3.tar.gz
3、进入cd nginx-1.10.3目录下
cd nginx-1.10.3
4、编译配置(参数详解参考)
按照需求配置或者使用默认配置 './configure'
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/conf/nginx.pid \
5、编译安装
make //编译文件
make test //测试编译文件 只有make test 完全通过才能执行 make install进行安装
make install //编译安装
6、添加环境变量
#打开profile文件
vim /etc/profile
#在profile文件尾部 添加环境变量
export PATH=/usr/local/nginx/sbin:$PATH
export PATH
#执行profile文件使其立即生效
source /etc/profile
7、nginx相关命令
#启动
nginx
#检查配置
nginx -t
#退出
nginx -s quit
#重载
nginx -s reload
三、mysql编译安装
1、下载mysql
wegt https://downloads.mysql.com/archives/get/file/mysql-5.6.25.tar.gz
2、解压并进入解压后的文件
#解压文件
tar -zxvf mysql-5.6.25.tar.gz
#进入文件
cd mysql-5.6.25
3、编译配置
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
4、编译安装
make //编译文件
make test //测试编译文件 只有make test 完全通过才能执行 make install进行安装
make install //编译安装
5、目录授权
chown mysq:mysql /usr/local/mysql
6、设置环境变量
#打开profile文件
vim /etc/profile
#在profile文件尾部 添加环境变量
export PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
#执行profile文件使其立即生效
source /etc/profile
7、制成服务启动命令
cp support-files/mysql.server /etc/init.d/mysql
相关命令:
#启动服务
service mysql start
#停止mysql服务
service mysql stop
#重启mysql服务
service mysql restart
8、添加到开机启动项
chkconfig --add mysql
9、初始密码
grep "temporary password" /var/log/mysqld.log 查找初始密码
四、Redis编译安装
1、下载redis并编译安装(官网下载)
#下载安装文件
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
#解压安装文件
tar xzf redis-5.0.3.tar.gz
#进入解压文件
cd redis-5.0.3
#make编译安装
make
2、添加环境变量
#打开profile文件
vim /etc/profile
#在profile文件尾部 添加环境变量
export PATH=$PATH:$HOME/bin:/usr/local/redis-5.0.3/src
export PATH
#执行profile文件使其立即生效
source /etc/profile
五、PHPRedis扩展安装
1、下载phpredis扩展
git clone https://github.com/phpredis/phpredis.git
2、安装
#进入phpredis
cd phpredis
#php安装后的目录
/usr/local/php/bin/phpize
#设置配置 ‘/usr/local/php/bin/’为安装后的目录
./configure --with-php-config=/usr/local/php/bin/php-config
#编译
make
#编译测试
make test
#安装
make install
3、配置
#修改php.ini配置
vim /usr/local/php/lib/php.ini
#增加如下内容 , 路径为PHPRedis扩展安装完成的路径
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
#重启php-fpm
/etc/init.d/php-fpm restart
参考:
https://www.jb51.net/article/109228.htm
https://www.cnblogs.com/zhang-shijie/p/5294162.html
https://www.cnblogs.com/netsa/p/7088494.html
https://blog.csdn.net/post_mans/article/details/78519128?locationNum=2&fps=1
http://www.cnblogs.com/ssgeek/p/9223389.html
https://blog.csdn.net/gnail_oug/article/details/53230547
一个有趣的微信小程序,装机完毕休息一下吧~