CentOS 7编译安装Tengine+PHP+MariaDB全程笔记
安装环境:CentOS7 3.10.0-693.5.2.el7.x86_64
准备源码包:
pcre-8.41.tar.gz
openssl-1.0.1h.tar.gz
zlib-1.2.11.tar.gz
jemalloc-4.5.0.tar.bz2
tengine-2.1.0.tar.gz
libmcrypt-2.5.8.tar.gz
php-7.1.11.tar.gz
首先安装nginx
安装基础依赖:
#yum install -y gcc automake autoconf libtool make gcc-c++ zlib-devel openssl-devel vim which bzip2
编译安装pcre:
# tar zvxf pcre-8.41.tar.gz
# cd pcre-8.41
# ./configure --prefix=/usr/local/TPM
# make && make install
编译安装openssl:
# tar zvxf openssl-1.0.1h.tar.gz
# cd openssl-1.0.1h
# ./config --prefix=/usr/local/TPM
# make && make install
编译安装zlib:
# tar zvxf zlib-1.2.11.tar.gz
# cd zlib-1.2.11
# ./configure --prefix=/usr/local/TPM
# make && make install
编译安装jemalloc:
# tar jxvf jemalloc-4.5.0.tar.bz2
# cd jemalloc-4.5.0
# ./configure --prefix=/usr/local/TPM
# make && make install
建立www用户组和用户,禁止www登陆shell:
# groupadd www
# useradd -g www www
# usermod -s /sbin/nologin www
创建虚拟主机使用目录,并赋予相应权限:
# mkdir -p /var/www/example.com/{public_html,logs}
# chmod -R +w /var/www/
# chown -R www:www /var/www/
编译安装Tengine:
# cd /usr/local/src/
# wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
# tar zvxf tengine-2.1.0.tar.gz
# cd tengine-2.1.0
# ./configure --prefix=/usr/local/TPM/nginx --user=www --group=www
--with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
--with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.11
--with-pcre=/usr/local/src/pcre-8.41 --with-jemalloc=/usr/local/src/jemalloc-4.5.0
# make && make install
修改nginx.conf文件:
# mkdir /usr/local/TPM/nginx/conf/domains
# vim /usr/local/TPM/nginx/conf/nginx.conf
修改
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
为
user www www;
worker_processes 4;
error_log logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
修改
http {
include mime.types;
default_type application/octet-stream;
为
http {
include mime.types;
include domains/*.conf;
default_type application/octet-stream;
测试Nginx:
# cd /usr/local/nginx
# ldconfig
# ./sbin/nginx -t
//有以下输出信息则为测试成功
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
添加Nginx到开机自动启动:
# vim /usr/lib/systemd/system/nginx.service
添加内容:
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设定开机启动:
# systemctl enable nginx
开启防火墙的80端口,或关闭防火墙(不推荐)。
此时使用浏览器访问localhost可看到Tengine的欢迎界面。
安装MariaDB
此处给出使用yum源的安装方法。
添加源:
# cd /etc/yum.repos.d/
# vim MariaDB.repo
输入内容:
# MariaDB 10.0 CentOS repository list - created 2014-09-30 09:33 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name =MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装MariaDB:
# yum install MariaDB-server MariaDB-client -y
启动MariaDB服务并添加开机自动启动:
# systemctl start mysql
# systemctl enable mysql
安装编译PHP
安装编译PHP的依赖:
# yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel
freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib
zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses
curl openssl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel
gmp-devel readline-devel libxslt-devel expat-devel xmlrpc-c xmlrpc-c-devel file
编译安装libmcrypt:
# tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make && make install
编译安装PHP:
# tar -zxvf php-7.1.11.tar.gz
# cd /tmp/build/php-7.1.11
# ./configure --prefix=/usr/local/TPM/php-7.1.11 --with-mysql --with-mysql-sock
--with-mysqli --enable-fpm --enable-soap --with-libxml-dir --with-openssl
--with-mcrypt=/usr/local/TPM/ --with-mhash --with-pcre-regex --with-sqlite3
--with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl
--with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter
--with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir
--with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf
--enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json
--enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl
--with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite
--with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets
--enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir
--with-xsl --enable-zip --enable-mysqlnd-compression-support --enable-pcntl --with-pear
# make && make install
复制配置文件及启动文件:
# cp /usr/local/TPM/php-7.1.11/etc/php-fpm.conf.default /usr/local/TPM/php-7.1.11/etc/php-fpm.conf
# cd /usr/local/TPM/php-7.1.11/etc/php-fpm.d/www.conf.default /usr/local/TPM/php-7.1.11/etc/php-fpm.d/www.conf
# cp /tmp/build/php-7.1.11/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
设置php-fpm开机自动启动:
# chmod a+x /etc/init.d/php-fpm
# chkconfig php-fpm on
将PHP的bin目录加入环境变量:
# chmod +x /etc/profile
# vim /etc/profile.d/php.sh
输入内容:
PATH=$PATH:/usr/local/php5.6.32/bin
export PATH
重载环境变量并配置启动文件:
# chmod +x /etc/profile.d/php.sh
# source /etc/profile
# ln -s /usr/local/TPM/php-7.1.11/sbin/php-fpm /bin/php-fpm
创建网站配置文件:
# vim /usr/local/TPM/nginx/conf/domains/example.com.conf
输入内容:
server {
server_name example.com;
listen 80;
root /var/www/example.com/public_html;
access_log /var/www/example.com/logs/access.log;
error_log /var/www/example.com/logs/error.log;
index index.php;
location /{
try_files $uri $uri//index.php?q=$uri&$args;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~/\.ht {
deny all;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
重启nginx:
# systemctl restart nginx
创建测试phpinfo.php:
# cd /var/www/example.com/public_html
# vim phpinfo.php
输入内容:
<?php
phpinfo();
?>
此时使用浏览器访问localhost/phpinfo.php可看到PHP的安装信息。
CentOS 7编译安装Tengine+PHP+MariaDB全程笔记的更多相关文章
- Centos7 编译安装 Nginx、MariaDB、PHP
前言 本文主要大致介绍CentOS 7下编译安装Nginx.MariaDB.PHP.面向有Linux基础且爱好钻研的朋友.技艺不精,疏漏再所难免,还望指正. 环境简介: 系统: CentOS 7,最小 ...
- centos7 yum安装nginx和 编译安装tengine
说明 我这里给大家演示一下如何安装nginx,nginx我就不多介绍了,然后我再说一点就是,安装的两种方法都可以,编译安装和yum安装,我不能每个都演示两遍呀,所以看到我这博客的你,学会举一反三好吧? ...
- centos下编译安装lnmp
centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...
- CentOS 7 编译安装 Code::Blocks
CentOS 7 编译安装 Code::Blocks yum install cairo-devel yum install pango-devel yum install atk-devel yum ...
- centos mysql 编译安装
centos mysql 编译安装 1.安装 创建MySQL用户 sudo useradd mysql 下载MySQL的源码包,我们这里使用的时5.5.18 安装依赖 sudo yum -y inst ...
- alpine编译安装tengine,并使用supervisor启动
Alpine是一个小型的linux系统,官方docker镜像只有不到5MB,非常适合作为容器镜像. Alpine Linux is a security-oriented, lightweight L ...
- debian7编译安装tengine添加lua和ldap模块
1.安装开发环境 # aptitute update # aptitude install -y build-essential # aptitude install -y libldap2-dev ...
- 转:在CentOS下编译安装GCC
转:https://teddysun.com/432.html 在CentOS下编译安装GCC 技术 秋水逸冰 发布于: 2015-09-02 更新于: 2015-09-02 6519 次围观 ...
- CentOS 下编译安装Apache
CentOS 下编译安装Apache 卸载原有的apache 首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz然后从 http://ap ...
随机推荐
- Oracle 中session和processes的初始设置
http://blog.163.com/succu/blog/static/193917174201252911727149/ 1.sessions 在初始化参数所设定的限制中,最为人所知的估计就 ...
- vim 模式查找
1. / 正向查找, ?反向查找 2. \v 激活very magic搜索模式,撰写正则表达式更接近于perl的正则表达式,大多数字符不需要进行转义 3. \V 激活noVeryMagic模式,按字符 ...
- RSA非对称算法实现HTTP密码加密传输
目前一般帐号系统,都是https来传输账户性息,申请一个https证书也不贵.但是网站的其它功能并不需要走https协议,https和http混布比较麻烦,所以决定先实现一个http协议传输RSA非对 ...
- 使用mysqld_multi 实现Mysql 5.6.36 + 5.7.18 单机多实例多版本安装
Mysql 5.6.36 + 5.7.18 单机多实例多版本安装 随着硬件层面的发展,各种高性能服务器如雨后春笋般出现,但高性能服务器不免造成浪费, MySQL单机多实例,是指在一台物理服务器上运行多 ...
- 规范-Git打标签与版本控制
Git打标签与版本控制规范 前言 本文适用于使用Git做VCS(版本控制系统)的场景. 用过Git的程序猿,都喜欢其分布式架构带来的commit快感.不用像使用SVN这种集中式版本管理系统,每一次提交 ...
- 获取网站的BaseURL
//get base URL var _urlstr = window.location.href; if (_urlstr.indexOf("? ...
- NERO8.0刻录系统光盘
正常启动NREO,点击NERO 8.0左下角图标(启动NERO应用程序和工具),选NERO Express Essentials,在左边的几个选项中选择“映像.项目.复制”,右边选“光盘映像或保存的项 ...
- 用变量a给出下面的定义。[中国台湾某著名CPU生产公司2005年面试题]
(1)一个整型数(An integer)(2)一个指向整型数的指针(A pointer to an integer)(3)一个指向指针的指针,它指向的指针是指向一个整型数(A pointer to a ...
- 【BZOJ3796】Mushroom追妹纸 二分+hash
[BZOJ3796]Mushroom追妹纸 Description Mushroom最近看上了一个漂亮妹纸.他选择一种非常经典的手段来表达自己的心意——写情书.考虑到自己的表达能力,Mushroom决 ...
- 【BZOJ4908】[BeiJing2017]开车 分块
[BZOJ4908][BeiJing2017]开车 Description 你有n辆车,分别a1, a2, ..., an位置和n个加油站,分别在b1, b2, ... ,bn .每个加油站只能支持一 ...