centos7 tengine2 mysql8 php7 LTMP编译安装

                                   图片描述

搭建环境阿里云主机centos7.3 64位纯镜像

最新LTMP版本
nginx redis php-fpm 启动脚本
链接: https://pan.baidu.com/s/1cnLB... 密码:6ge9
unzip script.zip -d /etc/init.d/
#添加权限
chmod a+x /etc/init.d/nginx
chmod a+x /etc/init.d/redis
chmod a+x /etc/init.d/php-fpm
#开机启动
chkconfig --add nginx
chkconfig nginx on

chkconfig --add redis
chkconfig redis on

chkconfig --add php-fpm
chkconfig php-fpm on

准备工作

定义目录

源码包存放路径 /home/soft
软件安装路径 /usr/local

mkdir -p /home/soft 
mkdir -p /usr/local

关闭防火墙 关闭SELinux 启动端口

#开启80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
#重启防火墙
firewall-cmd --reload
setenforce 0  #临时关闭SELinux 
#开机关闭SELinux  编辑/etc/selinux/config文件,将SELINUX的值设置为disabled。下次开机SELinux就不会启动了。 

systemctl stop firewalld  #临时关闭防火墙 
systemctl disable firewalld  #永久防火墙开机自关闭  

更改yum源

#替换成阿里云
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
#清除缓存
yum clean all
yum makecache

安装依赖包

yum -y install lrzsz gcc gcc-c++  net-tools perl  bzip2  vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

安装jemalloc

wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2
tar -xvf jemalloc-5.1.0.tar.bz2 && cd jemalloc-5.1.0
./configure --prefix=/usr/local/jemalloc --libdir=/usr/local/lib
make && make install

安装mysql8

#安装boost库
wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_66_0.tar.gz
tar -zxvf boost_1_66_0.tar.gz && mv boost_1_66_0  /usr/local/boost

#创建用户,用户组,且用户不能登录
groupadd -r mysql
useradd -r -g mysql -s /sbin/nologin -M mysql

#下载源码包
wget https://downloads.mysql.com/archives/get/file/mysql-8.0.11.tar.gz
tar -zxvf mysql-8.0.11.tar.gz && cd mysql-8.0.11
#编译参数安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc  -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BOOST=/usr/local/boost -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" -DWITH_SAFEMALLOC=OFF
make -j 4 && make install

#设置mysql安装目录的所有者和所属组
chown -R mysql:mysql /usr/local/mysql
#复制启动脚本到服务脚本目录
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#添加权限
chmod +x /etc/init.d/mysqld
#添加mysql软链
ln -s /usr/local/mysql/bin/* /usr/local/bin/
#设置默认文件权限
mkdir /var/log/mariadb 
touch /var/log/mariadb/mariadb.log 
chown -R mysql:mysql  /var/log/mariadb/

#初始化mysql
/usr/local/mysql/bin/mysqld  --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

注:最后一行是root用户密码(root@localhost: =5j1lshvpAvj)

mysql -uroot -p =5j1lshvpAvj
ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY '66666666'; #mysql8设置密码为6666666
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; #密码永远不过期
use mysql;#使用mysql库
update user set host='%' where user='root'; #设置任意主机都可以访问
FLUSH PRIVILEGES;#重新加载权限
exit;#退出

#开机自启动
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start

安装tengine2.2.2

#下载源码包
wget http://tengine.taobao.org/download/tengine-2.2.2.tar.gz 
tar -zxvf tengine-2.2.2.tar.gz && cd tengine-2.2.2 
#创建用户,用户组且用户并不能登录
groupadd tengine
useradd -g tengine tengine
useradd -r -g tengine -s /sbin/nologin -M tengine

#编译安装
./configure --prefix=/usr/local/nginx --user=tengine --group=tengine --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log --pid-path=/usr/local/nginx/nginx.pid --lock-path=/usr/local/nginx/lock/nginx.lock --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-http_limit_conn_module=shared --with-http_limit_req_module=shared --with-http_split_clients_module=shared --with-http_footer_filter_module=shared --with-http_sub_module=shared --with-http_access_module=shared --with-http_addition_module=shared --with-http_referer_module=shared --with-http_rewrite_module=shared --with-http_memcached_module=shared --with-ld-opt="-ljemalloc"
make -j4 && make install
#创建lock目录
mkdir /usr/local/nginx/lock

安装PHP7.2.8

#防止库文件找不到
cp -frp /usr/lib64/libldap* /usr/lib/
#创建PHP运行目录
mkdir -p /var/run/www/
#下载源码包
wget http://php.net/get/php-7.2.8.tar.bz2/from/this/mirror
tar -zxvf php-7.2.8.tar.gz && cd php-7.2.8
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring  --enable-ftp --with-gd  --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --without-gdbm --enable-session --enable-shared --disable-debug --with-iconv --with-iconv-dir --with-libxml-dir --enable-intl --with-pear --with-ldap=shared --enable-maintainer-zts  --with-libmbfl
make -j 4 && make install

#拷贝配置文件
cp php.ini-development /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
#添加环境变量
echo "export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/" >>/etc/profile
source /etc/profile

安装swoole

#下载源码包
wget https://github.com/swoole/swoole-src/archive/v4.0.4.tar.gz
tar -zxvf v4.0.4.tar.gz && cd swoole-src-4.0.4
phpize && ./configure && make && make install

#vi编辑 vi /usr/local/php/etc/php.ini  添加
extension=swoole.so

安装redis服务

#下载源码包
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar -zxvf redis-4.0.11.tar.gz && cd redis-4.0.11 
make PREFIX=/usr/local/redis install
cp /usr/local/src/redis/utils/redis_init_script /etc/init.d/redis
chkconfig --add redis
chkconfig redis on
cp redis.conf /etc/redis/6379.conf

echo "PATH="$PATH:/usr/local/redis/bin" >>/etc/profile
source  /etc/profile

安装PHPredis扩展

#下载源码包
wget https://pecl.php.net/get/redis-4.1.1.tgz
tar -zxvf redis-4.1.1.tgz && cd redis-4.1.1 && phpize && ./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
#vi编辑 vi /usr/local/php/etc/php.ini 添加
extension=redis.so

待续未完...

  1. 最新版本ltmp环境    √
  2. swoole启动PHP swoole+laravel
  3. centos7.3翻墙,编译安装V8,V8js扩展
  4. laravel+vue2.*+vue-cli3+V8js SSR服务器渲染
  5. Nginx+微信小程序直播推流

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值