//
# yum install gcc gcc-c++ openssl openssl-devel
安装Nginx
解压pcre
# wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
# tar -zxvf pcre-8.40.tar.gz 说明:不需要编译,只需要解压就行。
解压zlib
# wget http://zlib.net/zlib-1.2.11.tar.gz
# tar -zxvf zlib-1.2.11.tar.gz 说明:不需要编译,只需要解压就行。
解压nginx
# wget http://nginx.org/download/nginx-1.13.1.tar.gz
# tar -zxvf nginx-1.13.1.tar.gz
# ./configure --prefix=/usr/modules/nginx --with-pcre=/usr/modules/pcre --with-zlib=/usr/modules/zlib --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module
./configure \
--prefix=/usr/local/nginx \ 安装目录
--with-http_stub_status_module \ 开启nginx状态监控,默认不开启
--with-http_ssl_module \ 开启是否可以用https请求
--with-http_realip_module \ 开启反向代理时获取真实IP
--with-http_sub_module \ gx_http_sub_module模块是一个过滤器,它修改网站响应内容中的字符串,比如你想把响应内容中的‘ttlsa’全部替换成‘运维生存时间’
--with-http_gzip_static_module \ 开启gzip压缩
--with-pcre nginx rewrite依赖于PCRE库
--with-zlib:zlib是提供数据压缩用的函式库。
# make && make install
# ../nginx/sbin/nginx
配置:
vim nginx.conf
//注释一下内容,并copy一份把、scripts改为$document_root
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
include fastcgi_params;
}
完成上面的修改就可以让nginx来转发php的动态脚本请求。
不过目前还不能打开php文件,因为还没有打开php-fpm
创建一个新的用户和用户组来运行nginx,这样可以把nginx和root分开,保证nginx不具备root权限。但是,我们并不希望nginx成为一个真实的可以登陆到远程进行操作的用户,所以,我们并不给它创建家目录,在useradd的时候,用-M参数:
$ groupadd nginx
$ useradd -g nginx -M nginx
-g参数为nginx用户指定了一个组。-M参数保证其不自动生成home目录。
但通过上面的用户创建之后,nginx用户可以通过设置一个密码登陆到服务器,这个不是我们想要的,我们禁用它的ssh登陆权限.禁止用户登陆也很方便,只需要修改配置文件中有关用户和用户组的信息即可。
$ vim /etc/passwd
找到nginx,将后面的/bin/bash改为/sbin/nologin即可。
nginx常用命令
# ../nginx/sbin/nginx //启动nginx
# ../nginx/sbin/nginx -s reload //重启nginx
# ../nginx/sbin/nginx -s stop //关闭nginx
设置开机自启:vim /etc/rc.d/rc.local /usr/cboy/nginx/sbin/nginx 注意:rc.local必须拥有执行权限,如果没有 chmod a+x rc.local 添加)
///
安装PHP-Nginx(Nginx版本)
安装libxml2
# wget ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz
# tar -zxvf libxml2-2.9.4.tar.gz
# cd libxml2-2.9.4
# ./configure --prefix=/package/libxml2 --with-python=no
# make && make install
安装php
1.yum安装必需类库
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libpng libpng-devel
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel libmcrypt-devel freetype freetype-devel
yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel
# wget http://cn2.php.net/distributions/php-7.1.5.tar.gz
# tar -zxvf php-7.1.5.tar.gz
# cd php-7.1.5
[root@localhost php-src-php-7.1.6]# ./configure \
--prefix=/usr/local/php \ [php安装的根目录]
--exec-prefix=/usr/local/php \ [php执行文件所在目录]
--bindir=/usr/local/php/bin \ [php/bin目录]
--sbindir=/usr/local/php/sbin \ [php/sbin目录]
--includedir=/usr/local/php/include \ [php包含文件所在目录]
--libdir=/usr/local/php/lib/php \ [php/lib目录]
--mandir=/usr/local/php/php/man \ [php/man目录]
--with-config-file-path=/usr/local/php/etc \ [php的配置目录]
--with-mysql-sock=/var/run/mysql/mysql.sock \ [php的Unix socket通信文件]
--with-mcrypt \ [是php里面重要的加密支持扩展库,linux环境下该库在默认情况下不开启]
--with-mhash \ [Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启]
--with-openssl \ [OpenSSL 是一个安全套接字层密码库]
--with-mysqli=shared,mysqlnd \ [php依赖mysql库]
--with-pdo-mysql=shared,mysqlnd \ [php依赖mysql库]
--with-gd \ [gd库]
--with-iconv \ [关闭iconv函数,种字符集间的转换]
--with-zlib \ [zlib是提供数据压缩用的函式库]
--enable-zip \ [打开对zip的支持]
--enable-inline-optimization \ [优化线程]
--disable-debug \ [关闭调试模式]
--disable-rpath \ [关闭额外的运行库文件]
--enable-shared \ [启用动态库]
--enable-xml \ [开启xml扩展]
--enable-bcmath \ [打开图片大小调整,用到zabbix监控的时候用到了这个模块]
--enable-shmop \ [共享内存]
--enable-sysvsem \ [内存共享方案]
--enable-mbregex \ [开启多字节正则表达式的字符编码。]
--enable-mbstring \ [开启多字节字符串函数]
--enable-ftp \ [开启ftp]
--enable-gd-native-ttf \ [开启gd库原有字体]
--enable-pcntl \ [PHP的进程控制支持实现了Unix方式的多进程创建]
--enable-sockets \ [开启套节字]
--with-xmlrpc \ [打开xml-rpc的c语言]
--enable-soap \ [开启简单对象访问协议简单对象访问协议]
--without-pear \ [开启php扩展与应用库]
--with-gettext \ [开户php在当前域中查找消息]
--enable-session \ [允许php会话session]
--with-curl \ [允许curl扩展]
--with-jpeg-dir \ [指定jpeg安装目录yum安装过后不用再次指定会自动找到]
--with-freetype-dir \ [指定freetype安装目录yum安装过后不用再次指定会自动找到]
--enable-opcache \ [开启使用opcache缓存]
--enable-fpm \ [开启fpm]
--with-fpm-user=nginx \ [php-fpm的用户]
--with-fpm-group=nginx \ [php-fpm的用户组]
--without-gdbm \ [数据库函数使用可扩展散列和类似于标准UNIX dbm的工作]
--enable-fast-install \ [为快速安装优化]
--disable-fileinfo
./configure --prefix=/usr/modules/php7-n --with-mcrypt --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo
# make && make install
配置:
# cp ../php.ini-production ../php7-nginx/etc/php.ini
# cp php-fpm.conf.default php-fpm.conf
# cd ../php/etc/php-fpm.d/
# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# 设置PHP的时区
date.timezone = PRC
添加php的环境变量
vim /etc/profile
在末尾添加:
export PATH=$PATH:/usr/cboy/modules/php/bin
使profile文件生效
source /etc/profile
测试是否成功:php -v
php-fpm常用命令
# ./php-fpm -c ../etc/php.ini -y ../etc/php-fpm.conf //启动php-fpm,注意要带上配置文件,否则有可能启动时无法正确启动fpm,导致安装的模块无法识别
# kill -SIGUSR2 `cat ../php7-nginx/var/run/php-fpm.pid` //重启php-fpm
# kill -SIGINT `cat ../php7-nginx/var/run/php-fpm.pid` //关闭php-fpm
设置开机自启:vim /etc/rc.d/rc.local /usr/cboy/php7-nginx/sbin/php-fpm 注意:rc.local必须拥有执行权限,如果没有 chmod a+x rc.local 添加)
安装MySQL5.7
yum install libnuma*
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm更新本机的yum源
yum install mysql-community-{server,client,common,libs}-*
---------------------------------------------------------------------------------------------------------------------
上面的方法安装时如果网速不好就很慢,所以可以通过下面的方法安装
这五个包为基本包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el7.x86_64.rpm
不一定通过wget获取也可以下载后上传
rpm -Uvh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-server-5.7.18-1.el7.x86_64.rpm
--------------------------------------------------------------------------------------------------------------------
启动:systemctl start mysqld
开机启动
systemctl enable mysqld
systemctl disable mysqld
# systemctl daemon-reload #重新载入 systemd,扫描新的或有变动的单元
修改密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log # 获取临时密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx';
flush privileges;
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,一般需要新建一个用户
CREATE USER 'xxx'@'%' IDENTIFIED BY 'xxx';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'%' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'xxxxx'@'%' IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
重新启动mysql服务:systemctl restart mysqld
默认配置文件路径: 配置文件:/etc/my.cnf 日志文件:/var/log//var/log/mysqld.log 服务启动脚本:/usr/lib/systemd/system/mysqld.service socket文件:/var/run/mysqld/mysqld.pid
或者通过find / -name "mysql" 查看
httpd安装
1、apr 2、apr-util 3、pcre 4、httpd
apr
apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
--------------------------------------------
pcre
httpd
./configure \
--prefix=/usr/cboy/modules/httpd \ 安装目录
--enable-so \ 启动动态加载模块支持
--enable-rewrite \ 启动网页地址重写功能
--enable-mods=shared=most \ 启动上传共享
--with-mpm=worker \
--disable-cgid \ 关闭CGID
--disable-cgi \ 关闭CGI脚本程序支持
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
--with-ssl=/usr/local/openssl 支持https
--enable-ssl
./configure --prefix=/usr/modules/httpd --enable-so --enable-rewrite --enable-mods=shared=most --with-mpm=worker --disable-cgid --disable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl --enable-ssl
make && make install
添加 AddType application/x-httpd-php .php
添加index.php 在直接访问ip时可以直接识别PHP文件:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
启动:bin/apachectl start
添加开机启动:
在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/cboy/httpd/bin/apachectl start
///
安装PHP(httpd版本)
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel libmcrypt-devel freetype freetype-devel
配置编译(注意必须首先安装好依赖包,否则编译无法通过)
./configure --prefix=/usr/modules/php7-h \
--with-config-file-path=/usr/modules/php7-h/etc \
--with-config-file-scan-dir=/usr/modules/php7-h/etc/php.d \
--with-mcrypt=/usr/local/lib/libmcrypt \
--with-apxs2=/usr/modules/httpd/bin/apxs \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
make && make install
make clean
报错:
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
解决办法:
vi ../httpd/bin/apxs
找“/replace/with/path/to/perl/interpreter”关键字
在第一个行 :#!/replace/with/path/to/perl/interpreter -w
根据perl的安装目录 /usr/bin/perl
修改为:#! /usr/bin/perl -w
cp /usr/modules/php7-src/php.ini-production /usr/modules/php7-h/etc/php.ini
添加php的环境变量
vim /etc/profile
在末尾添加:
export PATH=$PATH:/usr/modules/php7-h/bin
使profile文件生效
source /etc/profile
测试是否成功:php -v
# yum install gcc gcc-c++ openssl openssl-devel
安装Nginx
解压pcre
# wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
# tar -zxvf pcre-8.40.tar.gz 说明:不需要编译,只需要解压就行。
解压zlib
# wget http://zlib.net/zlib-1.2.11.tar.gz
# tar -zxvf zlib-1.2.11.tar.gz 说明:不需要编译,只需要解压就行。
解压nginx
# wget http://nginx.org/download/nginx-1.13.1.tar.gz
# tar -zxvf nginx-1.13.1.tar.gz
# ./configure --prefix=/usr/modules/nginx --with-pcre=/usr/modules/pcre --with-zlib=/usr/modules/zlib --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module
./configure \
--prefix=/usr/local/nginx \ 安装目录
--with-http_stub_status_module \ 开启nginx状态监控,默认不开启
--with-http_ssl_module \ 开启是否可以用https请求
--with-http_realip_module \ 开启反向代理时获取真实IP
--with-http_sub_module \ gx_http_sub_module模块是一个过滤器,它修改网站响应内容中的字符串,比如你想把响应内容中的‘ttlsa’全部替换成‘运维生存时间’
--with-http_gzip_static_module \ 开启gzip压缩
--with-pcre nginx rewrite依赖于PCRE库
--with-zlib:zlib是提供数据压缩用的函式库。
# make && make install
# ../nginx/sbin/nginx
配置:
vim nginx.conf
//注释一下内容,并copy一份把、scripts改为$document_root
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
include fastcgi_params;
}
完成上面的修改就可以让nginx来转发php的动态脚本请求。
不过目前还不能打开php文件,因为还没有打开php-fpm
创建一个新的用户和用户组来运行nginx,这样可以把nginx和root分开,保证nginx不具备root权限。但是,我们并不希望nginx成为一个真实的可以登陆到远程进行操作的用户,所以,我们并不给它创建家目录,在useradd的时候,用-M参数:
$ groupadd nginx
$ useradd -g nginx -M nginx
-g参数为nginx用户指定了一个组。-M参数保证其不自动生成home目录。
但通过上面的用户创建之后,nginx用户可以通过设置一个密码登陆到服务器,这个不是我们想要的,我们禁用它的ssh登陆权限.禁止用户登陆也很方便,只需要修改配置文件中有关用户和用户组的信息即可。
$ vim /etc/passwd
找到nginx,将后面的/bin/bash改为/sbin/nologin即可。
nginx常用命令
# ../nginx/sbin/nginx //启动nginx
# ../nginx/sbin/nginx -s reload //重启nginx
# ../nginx/sbin/nginx -s stop //关闭nginx
设置开机自启:vim /etc/rc.d/rc.local /usr/cboy/nginx/sbin/nginx 注意:rc.local必须拥有执行权限,如果没有 chmod a+x rc.local 添加)
///
安装PHP-Nginx(Nginx版本)
安装libxml2
# wget ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz
# tar -zxvf libxml2-2.9.4.tar.gz
# cd libxml2-2.9.4
# ./configure --prefix=/package/libxml2 --with-python=no
# make && make install
安装php
1.yum安装必需类库
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libpng libpng-devel
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel libmcrypt-devel freetype freetype-devel
yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel
# wget http://cn2.php.net/distributions/php-7.1.5.tar.gz
# tar -zxvf php-7.1.5.tar.gz
# cd php-7.1.5
[root@localhost php-src-php-7.1.6]# ./configure \
--prefix=/usr/local/php \ [php安装的根目录]
--exec-prefix=/usr/local/php \ [php执行文件所在目录]
--bindir=/usr/local/php/bin \ [php/bin目录]
--sbindir=/usr/local/php/sbin \ [php/sbin目录]
--includedir=/usr/local/php/include \ [php包含文件所在目录]
--libdir=/usr/local/php/lib/php \ [php/lib目录]
--mandir=/usr/local/php/php/man \ [php/man目录]
--with-config-file-path=/usr/local/php/etc \ [php的配置目录]
--with-mysql-sock=/var/run/mysql/mysql.sock \ [php的Unix socket通信文件]
--with-mcrypt \ [是php里面重要的加密支持扩展库,linux环境下该库在默认情况下不开启]
--with-mhash \ [Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下不开启]
--with-openssl \ [OpenSSL 是一个安全套接字层密码库]
--with-mysqli=shared,mysqlnd \ [php依赖mysql库]
--with-pdo-mysql=shared,mysqlnd \ [php依赖mysql库]
--with-gd \ [gd库]
--with-iconv \ [关闭iconv函数,种字符集间的转换]
--with-zlib \ [zlib是提供数据压缩用的函式库]
--enable-zip \ [打开对zip的支持]
--enable-inline-optimization \ [优化线程]
--disable-debug \ [关闭调试模式]
--disable-rpath \ [关闭额外的运行库文件]
--enable-shared \ [启用动态库]
--enable-xml \ [开启xml扩展]
--enable-bcmath \ [打开图片大小调整,用到zabbix监控的时候用到了这个模块]
--enable-shmop \ [共享内存]
--enable-sysvsem \ [内存共享方案]
--enable-mbregex \ [开启多字节正则表达式的字符编码。]
--enable-mbstring \ [开启多字节字符串函数]
--enable-ftp \ [开启ftp]
--enable-gd-native-ttf \ [开启gd库原有字体]
--enable-pcntl \ [PHP的进程控制支持实现了Unix方式的多进程创建]
--enable-sockets \ [开启套节字]
--with-xmlrpc \ [打开xml-rpc的c语言]
--enable-soap \ [开启简单对象访问协议简单对象访问协议]
--without-pear \ [开启php扩展与应用库]
--with-gettext \ [开户php在当前域中查找消息]
--enable-session \ [允许php会话session]
--with-curl \ [允许curl扩展]
--with-jpeg-dir \ [指定jpeg安装目录yum安装过后不用再次指定会自动找到]
--with-freetype-dir \ [指定freetype安装目录yum安装过后不用再次指定会自动找到]
--enable-opcache \ [开启使用opcache缓存]
--enable-fpm \ [开启fpm]
--with-fpm-user=nginx \ [php-fpm的用户]
--with-fpm-group=nginx \ [php-fpm的用户组]
--without-gdbm \ [数据库函数使用可扩展散列和类似于标准UNIX dbm的工作]
--enable-fast-install \ [为快速安装优化]
--disable-fileinfo
./configure --prefix=/usr/modules/php7-n --with-mcrypt --with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo
# make && make install
配置:
# cp ../php.ini-production ../php7-nginx/etc/php.ini
# cp php-fpm.conf.default php-fpm.conf
# cd ../php/etc/php-fpm.d/
# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# 设置PHP的时区
date.timezone = PRC
添加php的环境变量
vim /etc/profile
在末尾添加:
export PATH=$PATH:/usr/cboy/modules/php/bin
使profile文件生效
source /etc/profile
测试是否成功:php -v
php-fpm常用命令
# ./php-fpm -c ../etc/php.ini -y ../etc/php-fpm.conf //启动php-fpm,注意要带上配置文件,否则有可能启动时无法正确启动fpm,导致安装的模块无法识别
# kill -SIGUSR2 `cat ../php7-nginx/var/run/php-fpm.pid` //重启php-fpm
# kill -SIGINT `cat ../php7-nginx/var/run/php-fpm.pid` //关闭php-fpm
设置开机自启:vim /etc/rc.d/rc.local /usr/cboy/php7-nginx/sbin/php-fpm 注意:rc.local必须拥有执行权限,如果没有 chmod a+x rc.local 添加)
安装MySQL5.7
yum install libnuma*
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm更新本机的yum源
yum install mysql-community-{server,client,common,libs}-*
---------------------------------------------------------------------------------------------------------------------
上面的方法安装时如果网速不好就很慢,所以可以通过下面的方法安装
这五个包为基本包
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el7.x86_64.rpm
不一定通过wget获取也可以下载后上传
rpm -Uvh mysql-community-common-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-client-5.7.18-1.el7.x86_64.rpm
rpm -Uvh mysql-community-server-5.7.18-1.el7.x86_64.rpm
--------------------------------------------------------------------------------------------------------------------
启动:systemctl start mysqld
开机启动
systemctl enable mysqld
systemctl disable mysqld
# systemctl daemon-reload #重新载入 systemd,扫描新的或有变动的单元
修改密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log # 获取临时密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxx';
flush privileges;
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,一般需要新建一个用户
CREATE USER 'xxx'@'%' IDENTIFIED BY 'xxx';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'%' IDENTIFIED BY 'xxxx' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'xxxxx'@'%' IDENTIFIED BY 'xxxxx' WITH GRANT OPTION;
配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
重新启动mysql服务:systemctl restart mysqld
默认配置文件路径: 配置文件:/etc/my.cnf 日志文件:/var/log//var/log/mysqld.log 服务启动脚本:/usr/lib/systemd/system/mysqld.service socket文件:/var/run/mysqld/mysqld.pid
或者通过find / -name "mysql" 查看
httpd安装
1、apr 2、apr-util 3、pcre 4、httpd
apr
./configure --prefix=/usr/local/apr
make && make install
apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
--------------------------------------------
pcre
./configure --prefix=/usr/local/pcre
make && make install
httpd
./configure \
--prefix=/usr/cboy/modules/httpd \ 安装目录
--enable-so \ 启动动态加载模块支持
--enable-rewrite \ 启动网页地址重写功能
--enable-mods=shared=most \ 启动上传共享
--with-mpm=worker \
--disable-cgid \ 关闭CGID
--disable-cgi \ 关闭CGI脚本程序支持
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
--with-ssl=/usr/local/openssl 支持https
--enable-ssl
./configure --prefix=/usr/modules/httpd --enable-so --enable-rewrite --enable-mods=shared=most --with-mpm=worker --disable-cgid --disable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl --enable-ssl
make && make install
make clean
添加 AddType application/x-httpd-php .php
添加index.php 在直接访问ip时可以直接识别PHP文件:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
启动:bin/apachectl start
添加开机启动:
在/etc/rc.d/rc.local中增加启动apache的命令,例如:/usr/cboy/httpd/bin/apachectl start
///
安装PHP(httpd版本)
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel libmcrypt-devel freetype freetype-devel
配置编译(注意必须首先安装好依赖包,否则编译无法通过)
./configure --prefix=/usr/modules/php7-h \
--with-config-file-path=/usr/modules/php7-h/etc \
--with-config-file-scan-dir=/usr/modules/php7-h/etc/php.d \
--with-mcrypt=/usr/local/lib/libmcrypt \
--with-apxs2=/usr/modules/httpd/bin/apxs \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
make && make install
make clean
报错:
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
解决办法:
vi ../httpd/bin/apxs
找“/replace/with/path/to/perl/interpreter”关键字
在第一个行 :#!/replace/with/path/to/perl/interpreter -w
根据perl的安装目录 /usr/bin/perl
修改为:#! /usr/bin/perl -w
cp /usr/modules/php7-src/php.ini-production /usr/modules/php7-h/etc/php.ini
添加php的环境变量
vim /etc/profile
在末尾添加:
export PATH=$PATH:/usr/modules/php7-h/bin
使profile文件生效
source /etc/profile
测试是否成功:php -v