二进制方法安装mysql5.7.27
1、准备工作
# yum remove mariadb-libs
# useradd -s /sbin/nologin -M mysql
# tar xf mysql-5.7.27-el7-x86_64.tar.gz -C /usr/local/
# cd /usr/local
# ln -sv mysql-5.7.27-el7-x86_64 mysql
# cd mysql
# chown -R root:root .
# mkdir -p /data/mysql
# chown mysql:mysql /data/mysql
2、初始化数据库
# bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize
2018-08-15T03:14:49.547844Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-15T03:14:50.223257Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-15T03:14:50.630089Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5f3e5156-a039-11e8-bb45-000c29df1867.
2018-08-15T03:14:50.672521Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-15T03:14:50.729802Z 1 [Note] A temporary password is generated for root@localhost: %xffgqDal2Ll #注意红色字体是root@localhost的临时密码
3、启动脚本
# cp support-files/mysql.server /etc/init.d/mysqld
4、配置环境变量
# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh && source /etc/profile.d/mysql.sh
5、my.cnf配置文件
# vim /etc/my.cnf
[mysqld]
log-bin
server-id=1
character-set-server=utf8
datadir=/data/mysql
socket=/data/mysql/mysql.sock
pid-file=/data/mysql/mysqld.pid
log_error=/data/mysql/mysql-error.log
skip_name_resolve=1
[client]
socket=/data/mysql/mysql.sock
6、启动服务
# chkconfig --add mysqld
# service mysqld start
7、登录数据库
# mysql -uroot -p‘%xffgqDal2Ll’ #这里就是生成的那个临时密码
首次登录数据库必须修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
编译安装php-7.1.29(fpm模式)
1、安装包版本
php-7.3.11.tar.xz
2、安装依赖包
# yum -y install epel-release
# yum -y install bzip2-devel libmcrypt-devel libxml2-devel openssl-devel
# yum -y groupinstall "development tools"
3、创建apache用户
# useradd -s /sbin/nologin -M apache
4、编译安装php-fpm
# tar xf php-7.3.11.tar.xz
# cd php-7.3.11
#./configure
--prefix=/usr/local/php-7.3.11
--enable-mysqlnd
--with-mysqli=mysqlnd
--with-openssl
--with-pdo-mysql=mysqlnd
--enable-mbstring
--with-freetype-dir
--with-jpeg-dir
--with-png-dir
--with-zlib
--with-libxml-dir=/usr
--enable-xml
--enable-sockets
--enable-fpm
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--enable-maintainer-zts
--disable-fileinfo
# make && make install
5、配置php
# cp php.ini-production /etc/php.ini
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
# cd /usr/local
# ln -sv php-7.3.11 php
# cd /usr/local/php/etc
# cp php-fpm.conf.default php-fpm.conf
# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# vim php-fpm.d/www.conf
user = apache
group = apache
# service php-fpm start
编译安装httpd-2.4.27
1、解压安装包
# tar xf apr-1.7.0.tar.gz
# tar xf apr-util-1.6.1.tar.gz
# tar xf httpd-2.4.39.tar.gz
2、安装依赖包
# yum -y install pcre-devel openssl-devel expat-devel
3、将apr和apr-util的源码放到httpd/srclib目录中
# mv apr-1.7.0 httpd-2.4.39/srclib/apr
# mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
4、编译安装httpd
# cd httpd-2.4.27/
./configure --prefix=/usr/local/httpd24
--enable-so
--enable-ssl
--enable-cgi
--enable-rewrite
--with-zlib
--with-pcre
--with-included-apr
--enable-modules=most
--enable-mpms-shared=all
--with-mpm=prefork
# make && make install
5、修改 httpd配置
当使用php-fpm模式时,配置httpd支持php
# vim /usr/local/httpd24/conf/httpd.conf
取消下面两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
修改主页文件
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
用户和组
User apache
Group apache
php跳转
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
创建虚拟主机配置
<VirtualHost *:80>
ServerName blog.ysu.com
DocumentRoot "/usr/local/httpd24/htdocs"
<Directory "/usr/local/httpd24/htdocs">
Options None
AllowOverride None
Require all granted
</Directory>
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/usr/local/httpd24/htdocs/$1
</VirtualHost>
6、修改环境变量,启动服务
# echo 'PATH=/usr/local/httpd24/bin:$PATH' > /etc/profile.d/httpd.sh
# source /etc/profile.d/httpd.sh
# apachectl
测试LAMP
创建测试用户密码
mysql> CRATE USER 'root'@'172.16.101.225' IDENTIFIED BY '123456';
创建测试页面index.php
<?php
$mysqli=new mysqli("172.16.101.225","root","123456");
if(mysqli_connect_errno()){
echo "Link to mysql failure..";
$mysqli=null;
exit;
}
echo "Link to mysql success..";
$mysqli->close();
?>
<?php
phpinfo();
?>