centos6.8 编译安装lnmp php7.2 mysql5.6 nginx1.1.4

编译操作参考版,没有每一步详细操作,慎入

关闭selinux和防火墙
service iptables stop
chkconfig iptables off
vi /etc/selinux/config 
把SELINUX=enforcing 修改为disabled

yum -y groupinstall "Development Tools" "Server Platform Development"

yum install -y gcc gcc-c++ make cmake automake autoconf gd file bison patch mlocate flex 
diffutils zlib zlib-devel pcre pcre-devel 
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel 
glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel 
ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel 
krb5 krb5-devel openssl openssl-devel 
openldap openldap-devel nss_ldap openldap-clients openldap-servers 
openldap-devellibxslt-devel kernel-devel libtool-libs 
readline-devel gettext-devel libcap-devel php-mcrypt libmcrypt libmcrypt-devel recode-devel

yum install -y libxml2 libxml2* openssl-dev libcurl3-openssl-dev openssl-devel.i686 
openssl-perl.i686 libcurl-devel.i686 libjpeg-turbo-devel.i686 libpng.i686 libpng-devel.i686l freetype-devel php-gd

yum -y install cmake ncurses ncurses-devel bison bison-devel boost boost-devel

yum -y install libicu-devel


查看系统版本
cat /etc/redhat-release

主要目录
/data/lanmp/soft
/data/www

安装mysql
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql

groupadd www
useradd -s /sbin/nologin -g www -M www

chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R www:www /usr/local/nginx
chown -R www:www /usr/local/php

chown -R www:www /data/wwwroot/

wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz


wget http://www.zlib.net/zlib-1.2.11.tar.gz


./configure 
--user=www 
--group=www 
--prefix=/usr/local/nginx


 nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

vi /etc/init.d/nginx

加执行权限
chmod +x /etc/init.d/nginx

开机启动
chkconfig nginx on

include vhosts/*.conf;

mysql


tar -xvzf boost_1_59_0.tar.gz -C /usr/local/boost


cmake 
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DMYSQL_DATADIR=/data/mysql/ 
-DSYSCONFDIR=/etc 
-DWITH_MYISAM_STORAGE_ENGINE=1 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_MEMORY_STORAGE_ENGINE=1 
-DWITH_READLINE=1 
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
-DMYSQL_TCP_PORT=3306 
-DENABLED_LOCAL_INFILE=1 
-DWITH_PARTITION_STORAGE_ENGINE=1 
-DEXTRA_CHARSETS=all 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci 
-DMYSQL_USER=mysql 
-DWITH_DEBUG=0 
-DWITH_SSL=system 
-DWITH_BOOST=/usr/local/boost

make && make install

#拷贝mysql安装目录下support-files服务脚本到init.d目录
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#赋予权限
chmod +x /etc/rc.d/init.d/mysqld

cd /usr/local/mysql


./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

mysql 密码
=jjhrEadh6dR


echo "PATH=$PATH:/usr/local/mysql/bin" > /etc/profile.d/mysql.sh
source /etc/profile

重置密码
set password = '123456';

新加远程访问用户,测试
GRANT ALL PRIVILEGES ON *.* TO 'zx'@'%'IDENTIFIED BY 'qyy@2018' WITH GRANT OPTION;
flush privileges;


php安装
yum remove libevent libevent-devel
yum install libevent2-devel libevent2

yum -y install openldap
yum -y install openldap-devel
cp -frp /usr/lib64/libldap* /usr/lib/

yum install -y epel-release
yum install -y libmcrypt-devel
export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH

./configure --prefix=/usr/local/php 
--with-config-file-path=/usr/local/php/etc 
--with-mysql-sock=/tmp/mysql.sock 
--enable-fpm 
--with-fpm-user=www 
--with-fpm-group=www 
--enable-mysqlnd 
--with-mysqli=mysqlnd 
--with-pdo-mysql=mysqlnd 
--enable-mysqlnd-compression-support 
--with-iconv-dir 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-zlib 
--with-libxml-dir 
--enable-xml 
--disable-rpath 
--enable-bcmath 
--enable-shmop 
--enable-sysvsem 
--enable-inline-optimization 
--with-curl 
--enable-mbregex 
--enable-mbstring 
--enable-intl 
--with-mcrypt 
--with-libmbfl 
--enable-ftp 
--with-gd 
--enable-gd-jis-conv 
--enable-gd-native-ttf 
--with-openssl 
--with-mhash 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-zip 
--enable-soap 
--with-gettext 
--enable-fileinfo 
--enable-opcache 
--with-pear 
--enable-maintainer-zts 
--with-ldap=shared 
--without-gdbm


mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
#注意:发现启动时错误,配置文件无法找到,需要mv /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/default.conf
#复制php.ini配置文件
cp php.ini-production /usr/local/php/etc/php.ini
#复制php-fpm启动脚本到init.d
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

service php-fpm start


 vi  /etc/profile
export PATH=$PATH:'/usr/local/php/bin/'
source /etc/profile

 cp /usr/local/src/php-7.2.9/php.ini-production /usr/local/php/etc/php.ini

cd /usr/local/php/etc/php-fpm.d
 cp www.conf.default www.conf

cd /usr/local/php/etc/
 mv php-fpm.conf.default php-fpm.conf



 /etc/hosts


nodejs
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -       8是版本系列
yum install -y nodejs

npm install -g cnpm --registry=https://registry.npm.taobao.org


curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

redis
yum -y install tcl
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
wget http://pecl.php.net/get/redis-4.1.1.tgz


扩展
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

/usr/local/php/lib/php/extensions/no-debug-zts-20170718/

/usr/local/php/lib/php/extensions/no-debug-zts-20170718/


mv ./redis-4.0.11 /usr/local/redis/
make && make install

mkdir /etc/redis
mv /usr/local/redis/redis.conf /etc/redis/redis.conf

cp /usr/local/redis/utils/redis_init_script /etc/rc.d/init.d/redis

chkconfig --add redis
chkconfig redis on

加入服 务失败

vi /etc/rc.d/init.d/redis  



ftp
yum -y install vsftpd

www用户
密码qyy@2018

chkconfig vsftpd on

vi /etc/vsftpd/vsftpd.conf

vi /etc/passwd

listen_port=2111
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
local_root=/data/wwwroot
pasv_enable=YES
pasv_min_port=10020
pasv_max_port=10040


cd /usr/local/php/bin/
wget http://pear.php.net/go-pear.phar -O go-pear.php

php go-pear.php

默认操作按 enter

ln -s /usr/local/php/bin/pecl /usr/bin/pecl

pecl install event
pecl install swoole

全部按找[yes]里面的默认推荐即可
extension=event.so
extension=swoole.so

datetime 默认问题
sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 
原文地址:https://www.cnblogs.com/zx-admin/p/9512462.html