系统
yum -y update # 对整个系统进行更新(包括内核),根据实际情况选择是否执行
yum -y install lrzsz wget gcc gcc-c++ git unzip vim screen nc lvm2 ruby jq # 安装一些系统常用软件
Nginx-1.10.2
# 依赖
yum -y install pcre-devel openssl openssl-devel
# 编译
./configure --prefix=/usr/local/nginx/ --with-http_flv_module --with-http_gzip_static_module --with-http_mp4_module --with-http_realip_module --with-http_secure_link_module --with-http_ssl_module --with-http_stub_status_module --with-http_dav_module
make
make install
# 启动
/usr/local/nginx/sbin/nginx
MySQL 5.7.16(官方下载的带 boost 的源码)
# 依赖
yum -y install ncurses-devel cmake bison autoconf
# 编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_unicode_ci -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/src/mysql-5.7.18/boost/boost_1_59_0/
make
make install
# 启动前的工作
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql/
mv /etc/my.cnf /etc/my.cnf.default
# 初始化脚本生成临时密码
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# 启动
/usr/local/mysql/support-files/mysql.server start
# 登陆
/usr/local/mysql/bin/mysql -u root -p # 回车后,输入上面生成的临时密码
# 重置系统生成的临时密码以及设置权限(如果不修改,则不能正常使用 MySQL)
SET PASSWORD = PASSWORD('123456');
GRANT ALL ON *.* to root@"%" IDENTIFIED BY "123456";
PHP 7.2.2
# 依赖 mhash
./configure --prefix=/usr/local/yilai/mhash
make
make install
# 依赖 libiconv(下载地址:https://www.gnu.org/software/libiconv/)
./configure --prefix=/usr/local/yilai/libiconv
make
make install
# 依赖 gettext(下载地址:下载地址:https://www.gnu.org/software/gettext/ )
./configure --prefix=/usr/local/yilai/gettext
make
make install
# yum 安装一些依赖
yum -y install python-devel libxml2 libpng libjpeg freetype gd libxml2-devel libcurl-devel libjpeg-devel libpng-devel libXpm-devel freetype-devel
# 编译
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --enable-mbstring --enable-ftp --enable-soap --enable-zip --enable-sockets --enable-shmop --enable-bcmath --enable-pcntl --enable-sysvsem --enable-mysqlnd --enable-embedded-mysqli --with-zlib --with-openssl --with-curl --with-xmlrpc --with-libxml-dir --with-xpm-dir --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-gd --with-libxml-dir --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-iconv-dir=/usr/local/yilai/libiconv --with-gettext=/usr/local/yilai/gettext --with-mhash=/usr/local/yilai/mhash --disable-fileinfo
make
make install
# 设置
cp 源码解压后的目录/php.ini-production /usr/local/php/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
# 启动
/usr/local/php/sbin/php-fpm
设置 Nginx、MySQL、PHP 环境变量
vi /etc/profile
nginx=/usr/local/nginx/sbin
mysql=/usr/local/mysql/bin
php=/usr/local/php/bin
export PATH=$PATH:$nginx:$mysql:$php
保存退出后 source /etc/profile
设置系统重启后 Nginx 自启动
# Nginx官方提供的脚本
https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/
# 建立自启动脚本
vi /etc/rc.d/init.d/nginx.server #内容就是官网提供的脚本,粘贴进来。
nginx="/usr/local/nginx/sbin/nginx" #编辑原文本的两处。配置自己的Nginx目录和配置文件
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" # 保存退出
# 设置权限,和自启动
chmod +x /etc/rc.d/init.d/nginx.server
chkconfig nginx.server on
设置系统重启后 MySQL 自启动
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql.server
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig mysql.server on
设置系统重启后 PHP 自启动
cp 下载的 php 源码路径/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm.server
chmod +x /etc/rc.d/init.d/php-fpm.server
chkconfig php-fpm.server on
附: