lnmp

夙愿已清 提交于 2020-12-19 08:31:35

实验环境


cat /etc/redhat-release 

CentOS release 6.5 (Final)


实验软件

cmake-3.7.2.tar.gz    

libmcrypt-2.5.8.tar.gz  

mhash-0.8.15.tar.gz  

libiconv-1.15.tar.gz  

mcrypt-2.6.8.tar.gz     

mysql-5.6.24.tar.gz

nginx-1.10.2.tar.gz

redis-4.0.2.tgz 

php-5.6.30.tar.gz


软件安装

cp -pv /etc/hosts /etc/hosts.bak  && echo 192.168.10.15 web1 > /etc/hosts

yum install -y gcc gcc-c++ autoconf automake libjpeg libjpeg-devel libpng libpng-devel

yum install -y freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel

yum install -y ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn

yum install -y libidn-devel libtool-ltdl-devel* openldap openldap-devel openldap-clients openldap-servers make

yum install -y zlib-devel pcre-devel* openssl-devel libtool* git tree bison* perl gd gd-devel fiex*


tar zxvf libiconv-1.15.tar.gz

cd libiconv-1.15

./configure --prefix=/usr/local/libiconv && make -j6 && make install


tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure && make -j6 && make install


tar zxvf mhash-0.8.15.tar.gz

cd mhash-0.8.15

./configure && make -j6 && make install


echo /usr/local/lib/ >> /etc/ld.so.conf && ldconfig

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

./configure && make -j6 && make install


tar zxvf cmake-3.7.2.tar.gz

cd cmake-3.7.2

./bootstrap && gmake && gmake install


groupadd mysql && useradd  -g mysql mysql

mkdir -pv /var/log/mysql

touch /var/log/mysql/{slow.log,mysql.err}

tar zxvf mysql-5.6.24.tar.gz 

cd mysql-5.6.24

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DMYSQL_USER=mysql \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DENABLE_DOWNLOADS=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_DEBUG=0 \

-DMYSQL_MAINTAINER_MODE=0 \

-DWITH_SSL:STRING=bundled \

-DWITH_ZLIB:STRING=bundled \

make -j6 && make install


chown -R mysql:mysql /usr/local/mysql/

cp -pv support-files/my-default.cnf /etc/my.cnf

cp -pv support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld && chkconfig --level 35 mysqld on


cp -pv /etc/my.cnf  /etc/my.cnf.bak

cat /etc/my.cnf

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

log-error = /var/log/mysql/mysql.err

slow_query_log = 1

slow_query_log_file = /var/log/mysql/slow.log 


/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ 

--datadir=/usr/local/mysql/data   --user=mysql &   初始化数据库

service  mysqld restart  && chkconfig --level 35 mysqld on


cp -pv /usr/local/mysql/bin/{mysql,mysqld,mysqladmin} /usr/bin/

mysqladmin  -uroot password 数据库密码

mysql -uroot -p123.com

mysql> 

mysql --version

mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper


tar zxvf php-5.6.30.tar.gz

cd php-5.6.30.tar.gz

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-mhash --with-mcrypt --enable-bcmath \

--enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \

--with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \

--with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \

--with-libxml-dir --enable-simplexml \

--enable-xml --disable-rpath \

--enable-bcmath --enable-soap --enable-zip \

--with-curl --enable-fpm \

--enable-mbstring --enable-sockets --with-gd --with-openssl \

--enable-opcache --disable-fileinfo

make -j6 && make install

cp -pv {php.ini-production,php.ini-development} /root/ 

cp -pv  php.ini-production /usr/local/php/etc/php.ini

cp -pv sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm && chkconfig --level 35 php-fpm on

cp -pv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp -pv /usr/local/php/sbin/{php-fpm,php} /usr/bin/


php-fpm -t

configuration file /usr/local/php/etc/php-fpm.conf test is successful

service php-fpm restart


tar zxvf nginx-1.10.2.tar.gz

cd nginx-1.10.2

./configure \

--prefix=/usr/local/nginx \

--with-http_stub_status_module \

--with-http_ssl_module \

--with-http_realip_module \

--without-http_limit_conn_module  \

--without-http_limit_req_module \

--with-pcre \

--pid-path=/var/run/nginx.pid

make -j6 && make install


cp -pv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

cp -pv /usr/local/nginx/sbin/nginx /usr/bin/


cat /usr/local/nginx/conf/nginx.conf

events {

use epoll;

worker_connections 1024;

}

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  -t

nginx  -c /usr/local/nginx/conf/nginx.conf && nginx  -s reload 平滑重启用于 从新加载配置文件

nginx -s stop && nginx  停止进程重启服务


echo test_html > /usr/local/nginx/html/index.html

curl http://localhost/index.html

test_html

touch /usr/local/nginx/html/index.php

echo '<?php phpinfo(); ?>' > /usr/local/nginx/html/index.php


http://serverip/index.php

1.jpg


安装php组件

tar zxvf redis-4.0.2.tgz

cd redis-4.0.2

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --enable-redis

make -j6 && make install 

Installing shared extensions:  /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/


cp -pv /etc/php.ini  /etc/php.ini.bak

extension_dir = 

cp -pv /etc/hosts /etc/hosts.bak  && echo 192.168.10.15 web1 > /etc/hosts


yum install -y gcc gcc-c++ autoconf automake libjpeg libjpeg-devel libpng libpng-devel

yum install -y freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel

yum install -y ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn

yum install -y libidn-devel libtool-ltdl-devel* openldap openldap-devel openldap-clients openldap-servers make

yum install -y zlib-devel pcre-devel* openssl-devel libtool* git tree bison* perl gd gd-devel fiex*


tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv && make -j6 && make install


tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure && make -j6 && make install


tar zxvf mhash-0.8.15.tar.gz

cd mhash-0.8.15

./configure && make -j6 && make install


echo /usr/local/lib/ >> /etc/ld.so.conf && ldconfig

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

./configure && make -j6 && make install


tar zxvf cmake-3.7.2.tar.gz

cd cmake-3.7.2

./bootstrap && gmake && gmake install


groupadd mysql && useradd  -g mysql mysql

mkdir -pv /var/log/mysql

touch /var/log/mysql/{slow.log,mysql.err}


tar zxvf mysql-5.6.24.tar.gz 

cd mysql-5.6.24

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DSYSCONFDIR=/etc \

-DMYSQL_USER=mysql \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DENABLE_DOWNLOADS=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_DEBUG=0 \

-DMYSQL_MAINTAINER_MODE=0 \

-DWITH_SSL:STRING=bundled \

-DWITH_ZLIB:STRING=bundled \

make -j6 && make install


chown -R mysql:mysql /usr/local/mysql/

cp -pv support-files/my-default.cnf /etc/my.cnf

cp -pv support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld && chkconfig --level 35 mysqld on


cp -pv /etc/my.cnf /etc/my.cnf.bak

cat /etc/my.cnf

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

log-error = /var/log/mysql/mysql.err

slow_query_log = 1

slow_query_log_file = /var/log/mysql/slow.log 


/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ 

--datadir=/usr/local/mysql/data   --user=mysql &   初始化数据库

service  mysqld restart


cp -pv /usr/local/mysql/bin/{mysql,mysqld,mysqladmin} /usr/bin/

mysqladmin  -uroot password 数据库密码

mysql -uroot -p123.com

mysql> 

mysql --version

mysql  Ver 14.14 Distrib 5.6.24, for Linux (x86_64) using  EditLine wrapper


tar zxvf php-5.6.30.tar.gz

cd php-5.6.30.tar.gz

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-mhash --with-mcrypt --enable-bcmath \

--enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql \

--with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-freetype-dir \

--with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \

--with-libxml-dir --enable-simplexml \

--enable-xml --disable-rpath \

--enable-bcmath --enable-soap --enable-zip \

--with-curl --enable-fpm \

--enable-mbstring --enable-sockets --with-gd --with-openssl \

--enable-opcache --disable-fileinfo

make -j6 && make install

cp -pv {php.ini-production,php.ini-development} /root/ 

cp -pv  php.ini-production /usr/local/php/etc/php.ini

cp -pv sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm && chkconfig --level 35 php-fpm on

cp -pv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp -pv /usr/local/php/sbin/php-fpm /usr/bin/


php-fpm -t

configuration file /usr/local/php/etc/php-fpm.conf test is successful

service php-fpm restart



tar zxvf nginx-1.10.2.tar.gz

cd nginx-1.10.2

./configure \

--prefix=/usr/local/nginx \

--with-http_stub_status_module \

--with-http_ssl_module \

--with-http_realip_module \

--without-http_limit_conn_module  \

--without-http_limit_req_module \

--with-pcre \

--pid-path=/var/run/nginx.pid

make -j6 && make install


cp -pv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

cp -pv /usr/local/nginx/sbin/nginx /usr/bin/


cat /usr/local/nginx/conf/nginx.conf

events {

use epoll;

worker_connections 1024;

}

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  -t

nginx  -c /usr/local/nginx/conf/nginx.conf && nginx  -s reload 平滑重启用于 从新加载配置文件

nginx -s stop && nginx  停止进程重启服务


echo test_html > /usr/local/nginx/html/index.html

curl http://localhost/index.html

test_html

touch /usr/local/nginx/html/index.php

echo '<?php phpinfo(); ?>' > /usr/local/nginx/html/index.php


http://serverip/index.php



安装php插件

tar zxvf redis-4.0.2.tgz

cd redis-4.0.2

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --enable-redis

make -j6 && make install 

Installing shared extensions:  /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/


cp -pv /etc/php.ini  /etc/php.ini.bak

extension_dir = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

extension = redis.so


service php-fpm restart

php -m | grep redis

redis

extension = redis.so


service php-fpm restart

php -m | grep redis

redis

2.jpg

配置域名虚拟主机

自签私有证书

配置https虚拟主机

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!