LNMP架构介绍与部署 (2)

[root@localhost mysql-5.7.20]#cmake \
-DCMAKE_INSTALL_PREFIX=http://www.likecs.com/usr/local/mysql \  指定将 mysql 数据库程序安装到某目录下
-DMYSQL_UNIX_ADDR=http://www.likecs.com/usr/local/mysql/mysql.sock \  通信文件
-DSYSCONFDIR=http://www.likecs.com/etc \      指定初始化参数文件目录
-DSYSTEMD_PID_DIR=http://www.likecs.com/usr/local/mysql \      进程文件位置
-DDEFAULT_CHARSET=utf8 \       指定默认使用的字符集校对规则
-DDEFAULT_COLLATION=utf8_general_ci \     指定默认使用的字符集校对规则
-DWITH_INNOBASE_STORAGE_ENGINE=1 \      存储使用引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \     存储使用引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \    存储使用引擎
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \     存储使用引擎
-DMYSQL_DATADIR=http://www.likecs.com/usr/local/mysql/data \      数据存放位置
-DWITH_BOOST=boost \     支持运行库
-DWITH_SYSTEMD=1
编译安装
[root@localhost mysql-5.7.20]#make && make install

 数据库目录进行权限调整

[root@localhost mysql-5.7.20]#chown -R mysql:mysql /usr/local/mysql/

 建立调整配置文件

[root@localhost mysql-5.7.20]#vi /etc/my.cnf

 [client]

port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

 [mysql]

port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

 [mysqld]

user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES

[root@localhost mysql-5.7.20]#chown mysql:mysql /etc/my.cnf

 

设置环境变量

 [root@localhost mysql-5.7.20]#echo 'PATH=http://www.likecs.com/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile

[root@localhost mysql-5.7.20]#echo 'export PATH' >> /etc/profile
[root@localhost mysql-5.7.20]#source /etc/profile

 [root@localhost mysql-5.7.20]#cd /usr/local/mysql/

 [root@localhost mysql]#bin/mysqld \

--initialize-insecure \
--user=mysql \
--basedir=http://www.likecs.com/usr/local/mysql \
--datadir=http://www.likecs.com/usr/local/mysql/data

[root@localhost mysql]#cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
[root@localhost mysql]#systemctl enable mysqld
[root@localhost mysql]#systemctl start mysqld
[root@localhost mysql]#systemctl status mysqld
[root@localhost mysql]#netstat -anpt | grep 3306

 [root@localhost mysql]#mysqladmin -u root -p password "abc123" //刚开始没密码是空的直接回车,然后输入密码abc123,在此确认abc123,这是在root账户下运行的

 [root@localhost mysql]#mysql -u root -p ##这个命令敲下,提示要输入密码,这个就是刚才设置的密码abc123

###PHP配置###

[root@localhost ~]# yum -y install \
libjpeg \
libjpeg-devel \支持图片格式
libpng libpng-devel \ 处理截图
freetype freetype-devel \
libxml2 \ 支持xml文件格式
libxml2-devel \
zlib zlib-devel \支持压缩
curl curl-devel \
openssl openssl-devel
将安装包传入/opt目录下
[root@localhost opt]# cd /opt
[root@localhost opt]# tar xf php-7.1.10.tar.bz2
[root@localhost opt]# cd php-7.1.10/
[root@localhost php-7.1.10/]# ./configure \
--prefix=http://www.likecs.com/usr/local/php \
--with-mysql-sock=http://www.likecs.com/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
[root@localhost php-7.1.10/]# make && make install
配置PHP的配置文件
php有三个配置文件 php.ini核心配置文件 php-fpm.conf进程服务配置文件 扩展配置文件
[root@localhost php-7.1.10/]# cp php.ini-development /usr/local/php/lib/php.ini
[root@localhost php-7.1.10/]# vi /usr/local/php/lib/php.ini
##找到以下两行的位置,修改这两行##
mysqli.default_socket = /usr/local/mysql/mysql.sock
date.timezone = Asia/Shanghai ##找到后,前方的;注释要去掉##
[root@localhost php-7.1.10]# /usr/local/php/bin/php -m ##验证安装的模块##
配置及优化FPM 模块
[root@localhost php-7.1.10]# cd /usr/local/php/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cd /usr/local/php/etc/php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf
[root@localhost php-fpm.d]# cd /usr/local/php/etc/
[root@localhost etc]# vi php-fpm.conf
pid = run/php-fpm.pid ##将;去掉##
;user = nginx
;group = nginx
路径优化
[root@localhost etc]# /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
[root@localhost etc]# netstat -natp |grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 99975/php-fpm: mast
[root@localhost etc]# ln -s /usr/local/php/bin/* /usr/local/bin/
[root@localhost etc]# ps aux | grep -c "php-fpm"
编辑nginx配置文件让nginx支持PHP功能
[root@localhost etc]# vi /usr/local/nginx/conf/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}                                    ##将;去掉,用/usr/local/nginx/html替换原来的路径##
[root@localhost etc]# vi /usr/local/nginx/html/index.php
<?php
phpinfo();
?>
[root@localhost etc]# killall -s HUP nginx          ##重启nginx##
然后网页测试就完成了

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpgzzs.html