CentOS
# zsh 主题 agnoster
# 下载PHP7源码包
$ wget -O php-7.1.5.tar.gz http://cn2.php.net/distributions/php-7.1.5.tar.gz
# 解压安装包
$ tar xf php-7.1.5.tar.gz
# 安装依赖包
$ cd php-7.1.5 && yum install -y 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
# 安装gcc编译器
$ yum -y install gcc
# 编译配置
$ ./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
# 安装
# make && make install
# Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/
# Installing PHP CLI binary: /usr/local/php/bin/
# Installing PHP CLI man page: /usr/local/php/php/man/man1/
# Installing PHP FPM binary: /usr/local/php/sbin/
# Installing PHP FPM defconfig: /usr/local/php/etc/
# Installing PHP FPM man page: /usr/local/php/php/man/man8/
# Installing PHP FPM status page: /usr/local/php/php/php/fpm/
# Installing phpdbg binary: /usr/local/php/bin/
# Installing phpdbg man page: /usr/local/php/php/man/man1/
# Installing PHP CGI binary: /usr/local/php/bin/
# Installing PHP CGI man page: /usr/local/php/php/man/man1/
# Installing build environment: /usr/local/php/lib/php/build/
# Installing header files: /usr/local/php/include/php/
# Installing helper programs: /usr/local/php/bin/
# program: phpize
# program: php-config
# Installing man pages: /usr/local/php/php/man/man1/
# page: phpize.1
# page: php-config.1
# Installing PEAR environment: /usr/local/php/lib/php/
# 配置环境变量
# 在/etc/profile末尾追加export PATH=$PATH:/usr/local/php/bin,然后执行source /etc/profile生效后查看php版本
# 配置php-fpm
# 安装完成后可以通过sapi/fpm/php-fpm.server来启动php-fpm了。不过为了以后管理方便,通常需要将配置文件统一放到
# /etc目录下,并将php-fpm.server添加至systemctl服务。如下:
# mkdir -p /etc/php-fpm.d
# cp php.ini-production /etc/php.ini
# cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/
# cp sapi/fpm/www.conf /etc/php-fpm.d/
# 然后更改/usr/lib/systemd/system/php-fpm.service文件使其执行正确的路径,如下:
[
[email protected] php-7.1.5]# vi /usr/lib/systemd/system/php-fpm.service
# It's not recommended to modify this file in-place, because it
# will be overwritten during upgrades. If you want to customize,
# the best way is to use the "systemctl edit" command.
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/var/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 启动php-fpm
# 第一次通过systemctl启动PHP服务时需要先将php-fpm服务enable:
# systemctl enable php-fpm.service
# systemctl start php-fpm.service
# ln /usr/local/php/sbin/php-fpm /usr/local/sbin # 软链接php-fpm
# 安装依赖包
# yum install -y gcc gcc-c++
# 安装PCRE库
$ cd /usr/local
$ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
$ tar -zxvf pcre-8.36.tar.gz
$ cd pcre-8.36
$ ./configure
$ make && make install
# 安装SSL库
$ cd /usr/local/
$ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz
$ tar -zxvf openssl-1.0.1j.tar.gz
$ cd openssl-1.0.1j
$ ./config
$ make && make install
# 安装zlib库存
$ cd /usr/local/
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz
$ ./configure
$ make && make install
# 安装Nginx
$ cd /usr/local/
$ wget http://nginx.org/download/nginx-1.8.0.tar.gz
$ tar -zxvf nginx-1.8.0.tar.gz
$ cd nginx-1.8.0
$ ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.33 --with-zlib=/usr/local/zlib-1.2.11
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
# 安装mysql
$ wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
$ rpm -ivh mysql-community-release-el7-5.noarch.rpm
$ yum install -y mysql-community-server
# 安装成功后重启mysql服务
$ service mysqld restart
# 初次安装mysql,root账户没有密码。设置密码, mysql -u root
$ set password for 'root'@'localhost'=password('passwd');
# 修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
$ mysql> character_set_server=utf8
init_connect='SET NAMES utf8' # 没看这个是设置什么字符的。
# 设置允许远程连接
$ grant all privileges on *.* to root@'%'identified by 'passwd';
# 如果允许root账号远程连接要对系统数据库的root账户设置远程访问的密码,与本地的root访问密码并不冲突。
$ grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; #123456为你需要设置的密码
# 设置开机启动
$ systemctl enable mysqld
$ systemctl daemon-reload
# 安装swoole
$ yum install tcl php-devel
$ pecl install swoole
$ wget http://download.redis.io/releases/redis-4.0.6.tar.gz # 去官网查找最新稳定版本 替换该地址
$ tar -zxvf redis-4.0.6.tar.gz # 解压文件
$ cd redis-4.0.6
$ make MALLOC=libc
$ make test
$ cd src && make install
# 启动redis服务
$ ./redis-server
# 以后台方式启动redis服务 修改redis.conf文件, 将 daemonize no 修改为 daemonize yes
# 指定redis.conf文件启动
$ ./redis-server /usr/local/redis-4.0.6/redis.conf
# 关闭redis进程
# 首先使用ps -aux | grep redis查看redis进程
[root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
$root 18714 0.0 0.1 141752 2008 ? Ssl 13:07 0:00 ./redis-server 127.0.0.1:6379
$root 18719 0.0 0.0 112644 968 pts/0 R+ 13:09 0:00 grep --color=auto redis
# 使用kill命令杀死进程
[root@iZwz991stxdwj560bfmadtZ src]# kill -9 18714
# 设置redis开机自启动
# 在etc目录创建redis文件夹
$ cd /etc && mkdir redis
# 将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf
$ cp /usr/local/redis-4.0.6/redis.conf /etc/redis/6379.conf
# 将redis的启动脚本复制一份放到/etc/init.d目录下
cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd
# 设置redis开机自启动
# 先切换到/etc/init.d目录下,然后执行自启命令
$ chkconfig redisd on
# 如果报错 service redisd does not support chkconfig , 使用vim编辑redisd文件,在第一行加入如下两行注释,保存退出
$ chkconfig: 2345 90 10
$ description: Redis is a persistent key-value database
# 再次执行开机自启命令,成功
$ chkconfig redisd
# 现在可以直接已服务的形式启动和关闭redis了
$ service redisd start
$ service redisd stop
$ service redisd start
# node 安装
# 获取nodejs 资源
# 4.x
# curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
# 5.x
# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# 0.10
# curl --silent --location https://rpm.nodesource.com/setup | bash -
$ yum install -y nodejs