• 相关依赖安装

yum -y install libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libicu-devel libmcrypt openssl openssl-devel glibc-headers gcc-c++ 
  • 到官网找一个适合的php源码包,下载回来之后解压/编译安装

tar -zxvf php-7.2.19.tar.gz

# 配置, 这个可以按照个人习惯更改路径等
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl

# 编译安装
make test
make install
  • 默认的配置

# 找到php-fpm
find / -name "php-fpm"

# copy默认配置
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

# 如果没有php.ini,就把php.ini 从源码包中copy出来
cp /root/php-package/php-7.2.19/php.ini-production /usr/local/php/etc/php.ini
  • 给php创建一个用户组/用户

groupadd www
useradd -g www www
  • 启动

  • 安装composer

# 移动一下php方便使用
cp /usr/local/php/bin/php /usr/bin/

# 安装官方操作

# 移动一下方便全局调用
mv composer.phar /usr/bin/composer
  • 安装扩展(laravel需要

# 安装aotuconf
yum -y install autoconf

# 源码安装包里
cd /root/php-package/php-7.2.19/ext/fileinfo

# 执行

# 某些情况perl会报错(待研究),需要另外设置环境变量
export LC_ALL=C

# 配置
./configure --with-php-config=/usr/local/php/bin/php-config

# make的时候发现不够内存,弄一下交换区。参考
dd if=/dev/zero of=~/swap_zone/centos-swap bs=1024 count=2048000

mkswap /root/swap_zone/centos-swap
mkswap -f /root/swap_zone/centos-swap
swapon /root/swap_zone/centos-swap

# 开启自启
# vim /etc/fstab
# 添加 /root/swap_zone/centos-swap swap swap default 0 0

# 继续装扩展
make test
make install

# 找到扩展存放路径
/usr/local/php/bin/php-config --extension-dir

# 在php.ini中添加配置
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/

nginx 安装

  • 安装依赖

yum install -y gcc openssl-devel pcre-devel zlib-devel
  • 创建用户

groupadd -r nginx 
useradd -r -g nginx -s /sbin/nologin -M nginx
  • 下载源码包

tar -zxvf nginx-1.16.0.tar.gz
cd nginx-1.16.0
  • 配置,编译,安装

-> ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/ --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre 

make instal

mysql 8

  • 依赖安装

yum -y install wget  cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel 
  • 下载源码包

# 需要带boost的版本

tar -zxvf mysql-boost-8.0.16.tar.gz
  • 创建用户

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
  • 创建安装目录和数据目录
 mkdir -p /usr/local/mysql
 mkdir -p /data/mysql
  • 安装cmake3
 yum install -y cmake3
  • 编译

-> cmake3 . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=/usr/local/mysql-8.0.16/boost
 # 这个时候遇到了错误:
 Please do not build in-source.  Out-of source builds are highly recommended: you can have multiple builds for the same source, and there is an easy way to do cleanup, simply remove the build directory (note that 'make clean' or 'make distclean' does *not* work)
  You *can* force in-source build by invoking cmake with -DFORCE_INSOURCE_BUILD=1
  -- Configuring incomplete, errors occurred!
  See also "/root/mysql-package/mysql-8.0.16/CMakeFiles/CMakeOutput.log".

# 参考文章:

# 按照文章上的操作失败, 估计是和cmake版本有关。 暂时放弃源码使用yum源安装
  • yum源安装

 # 在官网找到对应系统的yum源
 # 安装yum源
 yum install -y mysql80-community-release-el7-3.noarch.rpm

 # 安装mysql服务
 yum install -y mysql-community-server
 # 安装完成之后直接启动
 systemctl start mysqld
  • 修改密码

 # 获取默认密码
 cat /var/log/mysqld.log 
 # 登陆进去之后,先修改密码策略,再修改密码
 set global validate_password.policy=LOW;
 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '*********';
 # 添加远程登录的账号
 create user root@'%' identified by '******';
 grant all privileges on *.* to root@'%';
 flush privileges;
  • 远程登录

 # 登陆的时候遇到报错 :Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/, 2): image not found
 # 所以进行密码加密修改
  ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '********';


  • 下载,编译,安装

 tar zxvf redis-5.0.5.tar.gz
 cd redis-5.0.5
 make test
 # make test报错 :You need tcl 8.5 or newer in order to run the Redis test
 # 安装 tcl
 yum install -y tcl
 # 再次make test检查
 make test
 # 再次报错 *** [err]: Active defrag big keys in tests/unit/memefficiency.tcl Expected condition '$max_latency <= 120' to be true (125 <= 120)
 # 相关文章:
 # 忽略,直接安装
make install PREFIX=/usr/local/redis
  • 配置文件编辑

 # 找回默认的配置
 find / -name "redis.conf"
 # 迁到 etc 上
 cp /root/redis-package/redis-5.0.5/redis.conf /etc/redis.conf
  • 启动

 # 参考文章,添加redis启动到systemctl中
 cd /lib/systemd/system
 vim redis.service

 systemctl daemon-reload
 systemctl start redis


  • 直接yum安装

 yum install -y nodejs
  • nodejs版本管理

 # node.js版本管理器n
 npm install -g n
  • yarn

# 更新到最新
n latest
# 安装yarn
curl --silent --location | sudo tee /etc/yum.repos.d/yarn.repo
yum install -y yarn


  • git把项目拉下来
  • composer install
  • 配置nginx
  • 配置.env 文件
  • 日志文件权限
  • 前端文件build
  • DNS调整