系統(tǒng)
yum -y update # 對整個(gè)系統(tǒng)進(jìn)行更新(包括內(nèi)核),根據(jù)實(shí)際情況選擇是否執(zhí)行
yum -y install lrzsz wget gcc gcc-c++ git unzip vim screen nc lvm2 ruby jq # 安裝一些系統(tǒng)常用軟件
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
# 啟動(dòng)
/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
# 啟動(dòng)前的工作
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql/
mv /etc/my.cnf /etc/my.cnf.default
# 初始化腳本生成臨時(shí)密碼
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# 啟動(dòng)
/usr/local/mysql/support-files/mysql.server start
# 登陸
/usr/local/mysql/bin/mysql -u root -p # 回車后送滞,輸入上面生成的臨時(shí)密碼
# 重置系統(tǒng)生成的臨時(shí)密碼以及設(shè)置權(quán)限(如果不修改侠草,則不能正常使用 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
# 設(shè)置
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
# 啟動(dòng)
/usr/local/php/sbin/php-fpm
設(shè)置 Nginx、MySQL犁嗅、PHP 環(huán)境變量
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
設(shè)置系統(tǒng)重啟后 Nginx 自啟動(dòng)
# Nginx官方提供的腳本
https://www.nginx.com/resources/wiki/start/topics/examples/redhatnginxinit/
# 建立自啟動(dòng)腳本
vi /etc/rc.d/init.d/nginx.server #內(nèi)容就是官網(wǎng)提供的腳本边涕,粘貼進(jìn)來。
nginx="/usr/local/nginx/sbin/nginx" #編輯原文本的兩處。配置自己的Nginx目錄和配置文件
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" # 保存退出
# 設(shè)置權(quán)限功蜓,和自啟動(dòng)
chmod +x /etc/rc.d/init.d/nginx.server
chkconfig nginx.server on
設(shè)置系統(tǒng)重啟后 MySQL 自啟動(dòng)
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
設(shè)置系統(tǒng)重啟后 PHP 自啟動(dòng)
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
附: