一、安装nginx:下载:
a. nginx官网及安装包:

https://nginx.org/en/download.html或https://github.com/dollarphper/soft/blob/master/nginx/nginx-1.15.3.tar.gz安装:
a. 安装依赖:

yum -y install pcre-develyum -y install zlib-devel

b. 安装nginx:
cd nginx的下载目录

tar -xzf nginx-1.15.3.tar.gzcd nginx-1.15.3./configure && make && make install配置:
a. 创建nginx用户:

useradd -s /sbin/nologin -M nginx

b. 修改配置文件:
vim /usr/local/nginx/conf/nginx.conf

user nginx;worker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;client_max_body_size 8M;client_body_buffer_size 128k;server {listen 80;server_name localhost;gzip on;gzip_min_length 1k;gzip_comp_level 2;gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;gzip_vary on;gzip_disable "MSIE [1-6]\.";location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ { access_log off; expires 1h;}location ~* ^.+\.(css|js|txt|xml|swf|wav)$ { access_log off; expires 1h;}location ~* ^.+\.(html|htm)$ { expires 1h;}location ~* ^.+\.(eot|ttf|otf|woff|svg)$ { access_log off; expires max;}location / { add_header 'Access-Control-Allow-Origin' '*'; autoindex on; autoindex_localtime on; root html; index index.html index.htm; if (!-f $request_filename) { rewrite /(.*)$ /index.php/$1; } if (!-d $request_filename) { rewrite /(.*)$ /index.php/$1; }}location ~ \.php(.*)$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $1; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name; fastcgi_param PHP_VALUE "open_basedir=$document_root"; include fastcgi_params;}error_page 500 502 503 504 /50x.html;location = /50x.html { root html;}}}

c. 创建测试文件:

echo "hello world" > /usr/local/nginx/html/index.html启动命令:
a. 启动:

/usr/local/nginx/sbin/nginx

b. 停止:

/usr/local/nginx/sbin/nginx -s stop

c. 重启:

/usr/local/nginx/sbin/nginx -s reload

d. 添加环境变量:

echo 'export PATH=$PATH:/usr/local/nginx/sbin/' >> /etc/profile. /etc/profile

e. 添加启动脚本:
vim /etc/init.d/nginx

#!/bin/bashfunction start(){/usr/local/nginx/sbin/nginx}function stop(){/usr/local/nginx/sbin/nginx -s stop}case "$1" instart) start;; stop) stop;; restart) stop start;;*) echo "Usage : start | stop | restart";;esac

f. 加载nginx:

chmod +x /etc/init.d/nginxsystemctl daemon-reload

5.测试:

二、安装mysql:下载:

https://dev.mysql.com/downloads/mysql/或https://github.com/dollarphper/soft/blob/master/mysql/mysql-boost-8.0.12.tar.gz安装:
a. 安装依赖:

yum -y install cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel

b. 创建用户:

useradd mysql -s /sbin/nologin -M

c. 创建文件夹:

mkdir -p /usr/local/mysql/data

d. 解压:

tar -xzf mysql-boost-8.0.12.tar.gz

e. 编译安装:

cd mysql-8.0.12cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DMYSQL_TCP_PORT=3306 \-DWITH_BOOST=./boostmake && make install配置:
a. 修改mysql所属者为mysql:

chown -R mysql.mysql /usr/local/mysql

b. 修改配置文件:
vim /etc/my.cnf

[mysqld]server-id=1port=3306basedir=/usr/local/mysqldatadir=/usr/local/mysql/datangram_token_size=2

c. 初始化:

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/usr/local/mysql/data/usr/local/mysql/bin/mysql_ssl_rsa_setup

d. 启动服务:

/usr/local/mysql/bin/mysqld_safe --user=mysql &

e. 添加到环境变量:

echo 'export PATH=$PATH:/usr/local/mysql/bin/' >> /etc/profile. /etc/profile

f. 添加启动脚本:
vim /etc/init.d/mysqld

#!/bin/bashfunction start(){/usr/local/mysql/bin/mysqld_safe --user=mysql &}function stop(){/usr/bin/pkill mysqld}case "$1" instart) start;; stop) stop;; restart) stop start;;*) echo "Usage : start | stop | restart";;esac

g. 加载mysqld:

chmod +x /etc/init.d/mysqldsystemctl daemon-reload

h. 添加用户:

CREATE USER `root`@`%` IDENTIFIED BY '123456';

i. 授权:

GRANT ALL ON *.* TO `root`@`%` WITH GRANT OPTION;

j. 删除系统预留用户:

delete from mysql.user where host<>'%';

k. 刷新权限:

flush privileges;

l. 允许远程登录:
l-1. 设置变量:

SET GLOBAL innodb_fast_shutdown = 1;

l-2. 退出:

quit

l-3. 升级:

mysql_upgrade -u root -p123456测试:
/usr/local/mysql/bin/mysql

三、安装php:下载:

http://us1.php.net/downloads.php或https://github.com/dollarphper/soft/blob/master/php/php-7.2.10.tar.gz安装:
a. 安装依赖:

yum -y install libxml2 libxml2-develyum -y install curl-devel libjpeg-devel libpng-devel freetype-develyum -y install libicu-develyum -y install libxslt-develyum -y install openssl openssl-devel

b. 解压:

tar -xzf php-7.2.10.tar.gz

c. 编译:

cd php-7.2.10./configure \--prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-mysqlnd \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-iconv-dir \--with-freetype-dir=/usr/local/freetype \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--enable-mbregex \--enable-mbstring \--enable-intl \--enable-pcntl \--enable-ftp \--with-gd \--with-openssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--with-gettext \--disable-fileinfo \--enable-opcache \--enable-maintainer-zts \--with-xsl

d. 安装:

make && make install

e. 下载pthreads:

git clone https://github.com/krakjoe/pthreads.git

f. 安装pthreads:

cd pthreadsphpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make install

g. 开启pthreads扩展:
vim /usr/local/php/etc/php.ini

[pthreads]extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pthreads.so

h. 安装phpunit:
h-1. 下载:

wget -O phpunit https://phar.phpunit.de/phpunit-6.phar

h-2. 授权:

chmod +x phpunit

h-3. 添加到环境变量:

mv phpunit /usr/local/php/bin

i. 安装xdebug:
i-1. 下载:

git clone git://github.com/xdebug/xdebug.git

i-2. 进入目录:

cd xdebug

i-3. 生成编译文件:

/usr/local/php/bin/phpize

i-4. 编译:

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

i-5. 安装:

make && make install

i-6. 配置:

[xdebug]zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/xdebug.soxdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_mode=reqxdebug.remote_host=172.20.10.2xdebug.remote_port=9000xdebug.idekey="PHPSTORM"配置:
a. 拷贝配置文件:

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

b. 配置文件参考:

[PHP]engine = Onshort_open_tag = Offprecision = 14output_buffering = 4096zlib.output_compression = Offimplicit_flush = Offunserialize_callback_func =serialize_precision = -1disable_functions =disable_classes =zend.enable_gc = Onexpose_php = Onmax_execution_time = 30max_input_time = 60memory_limit = 512Merror_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTdisplay_errors = ondisplay_startup_errors = Offlog_errors = Onlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Onhtml_errors = Onvariables_order = "GPCS"request_order = "GP"register_argc_argv = Offauto_globals_jit = Onpost_max_size = 8Mauto_prepend_file =auto_append_file =default_mimetype = "text/html"default_charset = "UTF-8"doc_root =user_dir =enable_dl = Offfile_uploads = Onupload_max_filesize = 20Mmax_file_uploads = 20allow_url_fopen = Onallow_url_include = Offdefault_socket_timeout = 99999999date.timezone = PRC[CLI Server]cli_server.color = On[Date][filter][iconv][intl][sqlite3][Pcre][Pdo][Pdo_mysql]pdo_mysql.cache_size = 2000pdo_mysql.default_socket=[Phar][mail function]SMTP = localhostsmtp_port = 25mail.add_x_header = Off[ODBC]odbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1[Interbase]ibase.allow_persistent = 1ibase.max_persistent = -1ibase.max_links = -1ibase.timestampformat = "%Y-%m-%d %H:%M:%S"ibase.dateformat = "%Y-%m-%d"ibase.timeformat = "%H:%M:%S"[MySQLi]mysqli.max_persistent = -1mysqli.allow_persistent = Onmysqli.max_links = -1mysqli.cache_size = 2000mysqli.default_port = 3306mysqli.default_socket =mysqli.default_host =mysqli.default_user =mysqli.default_pw =mysqli.reconnect = Off[mysqlnd]mysqlnd.collect_statistics = Onmysqlnd.collect_memory_statistics = Off[OCI8][PostgreSQL]pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0[bcmath]bcmath.scale = 0[browscap][Session]session.save_handler = filessession.use_strict_mode = 0session.use_cookies = 1session.use_only_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = /session.cookie_domain =session.cookie_httponly =session.serialize_handler = phpsession.gc_probability = 1session.gc_divisor = 1000session.gc_maxlifetime = 1440session.referer_check =session.cache_limiter = nocachesession.cache_expire = 180session.use_trans_sid = 0session.sid_length = 26session.trans_sid_tags = "a=href,area=href,frame=src,form="session.sid_bits_per_character = 5[Assertion]zend.assertions = -1[COM][mbstring][gd][exif][Tidy]tidy.clean_output = Off[soap]soap.wsdl_cache_enabled=1soap.wsdl_cache_dir="/tmp"soap.wsdl_cache_ttl=86400soap.wsdl_cache_limit = 5[sysvshm][ldap]ldap.max_links = -1[dba][opcache][curl][openssl]

c. 添加php-fpm到系统启动目录:

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmsystemctl daemon-reload

d. 创建配置文件:
touch /usr/local/php/etc/php-fpm.conf

[global]pid = /usr/local/php/var/run/php-fpm.piderror_log = /usr/local/php/var/log/php-fpm.loglog_level = notice[nginx]listen = 127.0.0.1:9000listen.backlog = -1listen.allowed_clients = 127.0.0.1listen.owner = nginxlisten.group = nginxlisten.mode = 0666user = nginxgroup = nginxpm = dynamicpm.max_children = 20pm.start_servers = 10pm.min_spare_servers = 10pm.max_spare_servers = 20request_terminate_timeout = 100request_slowlog_timeout = 0slowlog = var/log/slow.log启动和停止:
a. 启动:

systemctl start php-fpm

b. 停止:

systemctl stop php-fpm

c. 重启:

systemctl restart php-fpm

d. 开机启动:

chkconfig php-fpm on

e. 添加环境变量:

echo 'export PATH=$PATH:/usr/local/php/bin/' >> /etc/profile. /etc/profile