基础依赖安装
# 编译安装基础依赖
yum install gcc gcc-c++ make cmake
Apache
# 1.安装依赖库:
yum install pcre pcre-devel apr apr-devel apr-util apt-util-devel
# 2.编译安装:
# Apache-2.2:
./configure --prefix=/usr/local/apache --with-pcre --with-included-apr --with-enable-mods-shared=most
# Aapche-2.4:
./configure --prefix=/usr/local/apr && make && make install #依赖apr
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config && make && make install #依赖apr-util
./configure --prefix=/usr/local/apache --with-pcre --with-apr=path --with-apr-util=path --with-enable-mods-shared=most
make && make install
# 一些说明:
# 编译安装的Apache的运行用户是'daemon'<Yum方式的安装的是Apache,可通过配置文件修改>;
# 可编译管理脚本进行服务管理,也可直接使用apachectl命令:apachectl -l -M -t graceful/start/stop/restart/status
Nginx
# 1.安装依赖库:
yum install pcre pcre-devel zlib zlib-devel
# 2.编译安装:
./configure --prefix=/usr/local/nginx --sbin-path=/usr/bin/nginx
make && make install
# 一些说明:
# 编译安装的Nginx的运行用户是'nobody'<Yum方式的安装的是nginx,可通过配置文件修改>;
# 可编译管理脚本进行服务管理,也可直接使用nginx命令:nginx -t,nginx -s reload/stop,
Mysql
# 1.安装依赖库:
yum install bison bison-devel ncurses ncurses-devel libaio libaio-devel
# 2.编译安装:
rm -rf CMakeCache.txt #删除Cmake缓存(如果有)
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_USER=mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_BOOST=/Path/To/Boost:Version>5.7
make && make install
# 3.建立启动用户并授权:
useradd -s /sbin/nologin -M mysql #创建mysql运行用户
chown -R mysql:mysql mysql/data mysqld.sock_dir mysqld.log_dir mysql.pid_dir #更改相关目录所有者和所属组
# 4.初始化数据库:
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql # Version<5.7.6
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql # Version>5.7.6
./bin/mysql_ssl_rsa_setup
# 5.配置文件和服务管理:
cp /suport-files/my-large.cnf /etc/my.cof #根据实际情况配置其中参数
cp /support-files/mysql.server /etc/init.d/mysqld #修改其中basedir/datadir相关字段
PHP For Apache
# PHP将做为Apache的模块使用而不是单独的服务;
# 1.安装PHP依赖库:
yum install openssl openssl-devel curl curl-devel bzip2 bzip2-devel libxml2 libxml2-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel
# 可能需要手动安装的依赖库(添加epel源可yum安装):
# libmcrypt:./configure --prefix=/usr/local/libmcrypt && make && make install
# 2.编译安装:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-mcrypt=/usr/local/libmcrypt --enable-mbstring --with-openssl --with-pear --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --enable-soap --enable-sockets --enable-exif --enable-gd-native-ttf --disable-ipv6
make && make install
# 配置文件和相关命令:
cp php.ini-production /usr/local/php/etc/php.ini #根据实际情况修改
php -im,phpize #查看php配置
PHP-FPM
# PHP作为单独的服务'php-fpm'启动;
# 1.安装PHP依赖库:
yum install openssl openssl-devel curl curl-devel bzip2 bzip2-devel libxml2 libxml2-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel
# 可能需要手动安装的依赖库(添加epel源可yum安装):
# libmcrypt:./configure --prefix=/usr/local/libmcrypt && make && make install
# 2.编译安装:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-libxml-dir --with-gd --with-mcrypt=/usr/local/libmcrypt --enable-mbstring --with-openssl --with-pear --with-curl --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --enable-soap --enable-sockets --enable-exif --enable-gd-native-ttf --disable-ipv6
make && make install
# 3.添加运行用户:
useradd -s /sbin/nologin -M php-fpm
# 4.配置文件和服务管理:
cp php.ini-production /usr/local/php/etc/php.ini #根据实际情况修改
cp /sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf #根据实际情况修改
cp /sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm #根据实际情况修改
php -im,phpize,php-fpm -imt #可编译管理脚本进行服务管理,也可直接使用命令方式