herohope 2020-01-02
一 安装MYSQL
# cd /usr/local/src
# wget http://mirrors.sohu.com/mysql/MYSQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
# mv mysql-5.6.35--linux-glibc2.5-x86_64.tar.gz /usr/local/mysql
# useradd -s /sbin/nologin mysql
# cd /usr/local/mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql
# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
编译前需要先安装 yum -y install perl perl -Module-Install
# cp support-files/my-default.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# vim /etc/init.d/mysqld
需要修改的地方 有 datadir=/data/mysql 把启动脚本加入系统服务项
# chkconfig --add mysqld
# chkconfig mysqld on //开启服务
# service mysqld start //启动mysql服务
查看MYSQL是否启动
# ps aux |grep mysqld
二 安装PHP
下载 PHP源码包
# cd /usr/local/src
# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
解压源码包
# tar zxf php-5.6.30.tar.gz
# useradd -s /sbin/nologin php-fpm
该账号用来运行php-fpm服务。在LNMP环境中,PHP以一个服务php-fpm形式出现,独立存在于linux系统中。方便管理
配置编译文件选项
# cd php-5.6.30
#./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl
错误信息:
解决方法
#yum -y install libjpeg-devel
编译PHP
# make
出现错误
解决方法
vim Makefile
// 大概在102行 -lcrypt 后面加 -lpthread
继续make
安装PHP
# make install
# echo $?
查看是否为0
修改配置文件
# cp php.ini-production /usr/local/php-fpm/etc/php.ini
# vim /usr/local/php-fpm/etc/php-fpm.conf
修改文件如下
[global]
pid = /usr/local/php-fpm/var/run/php-fpm. pid
error_
log = /usr/local/php- fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi. sock
listen.mode = 666
user =
php-fpm
group = php- fpm
pm = dynamic
pm.max_ children = 50
pm.start_ servers = 20
pm.min_ spare_ servers = 5
pm. max_ spare_ servers = 35
pm. max_ requests = 500
rlimit_ files = 1024
保存配置文件后 检验
# /usr/local/php-fpm/sbin/php-fpm -t
如果显示 test is successful 表明配置文件没有问题
启动php-fpm
# cp /usr/local/src/php-5.6. 30/sapi/ fpm/init.d.php- fpm /etc/ init.d/php-fpm
# chmod 755 /etc/init . d/php- fpm
# useradd -s /sbin/nologin php- fpm
# service php-fpm start
设置php-fpm开机自启
#chkconfig php-fpm on
检测php-fpm命令
# ps aux |grep php-fpm
执行后会看到大约20条命令