Centos 6.8编译安装LNMP环境(Nginx+MySQL+PHP)教程

2019-10-12 14:55:39于丽

这里又有一点要注意:mysql5.7配置文件需要修改my.cnf关键配置, mysql5.7之前默认配置文件中是有配置项的,不用手动修改。以下为配置,根据实际情况修改:

</div>
<div>[mysqld]</div>
<div>basedir = /usr/local/mysql</div>
<div>datadir = /mnt/data</div>
<div>port = 3306</div>
<div>socket = /Ultrapower/test/mysql/tmp/mysql.sock</div>
<div></div>
<div>sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES</div>
<div>[client]</div>
<div>socket = /Ultrapower/test/mysql/tmp/mysql.sock</div>
<div>

如果添加[client]下 的内容,注意sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES要放在[mysqld]下。
如果报错tmp目录不错在,到对应的地方去创建目录,然后创建后要赋予mysql权限,chown -R mysql:mysql tmp。

9. 设置开机启动

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysql

注册为开机启动服务:

# chkconfig mysqld on
# chkconfig –add mysqld

查看是否设置成功:

# chkconfig –list mysql

10. 设置PATH环境变量。

# echo “export PATH=$PATH:/usr/local/mysql/bin” > /etc/profile.d/mysql.sh
# source /etc/profile.d/mysql.sh

11. 启动服务

# service mysqld start

这样基本上,这个mysql就装好了。

12. 登录mysql并修改密码

mysql -uroot -p生成的密码

执行修改密码:

alter user ‘root'@'localhost' identified by ‘newpassword';

四 安装php-fpm

1. 安装依赖包:

yum install libmcrypt libmcrypt-devel mhash mhash-devel libxml2 libxml2-devel bzip2 bzip2-devel

这里还漏了几个,如果报错了提示缺少了什么就yum补上。

2. 到官网下载源码包后,开始编译安装:

# tar xvf php-7.0.16.tar.bz2 -C /usr/local/src
# cd /usr/local/src/php-7.0.16
执行下面的配置文件:
# ./configure --prefix=/usr/local/php 
--with-config-file-scan-dir=/etc/php.d 
--with-config-file-path=/etc 
--with-mysql=/usr/local/mysql 
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--enable-fpm 
--enable-opcache 
--disable-fileinfo 
--with-jpeg-dir 
--with-iconv-dir=/usr/local 
--with-freetype-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir=/usr 
--enable-xml 
--enable-bcmath 
--enable-shmop 
--enable-exif 
--with-curl 
--enable-sysvsem 
--enable-inline-optimization 
--enable-mbregex 
--enable-inline-optimization 
--enable-mbstring 
--with-mcrypt 
--with-gd 
--enable-gd-native-ttf 
--with-openssl 
--with-mhash 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-ftp 
--with-gettext 
--enable-zip 
--enable-soap 
--with-bz2