1、lnmp架构

2、mysql的安装:

mysql5.6自动安装脚本:

yum install perl-Data-Dumper.x86_64 libaio.x86_64 libaio-devel.x86_64 -y
useradd -M mysql -s /sbin/nologin
wget -c http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
tar -xvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
mv ./mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql56
chown -R mysql.mysql /usr/local/mysql56/
cd /usr/local/mysql56
./scripts/mysql_install_db --user="mysql" --basedir="/usr/local/mysql56" --datadir="/usr/local/mysql56/data" --defaults-file="/etc/mysql.cnf" --socket="/tmp/mysqld.sock"
cp support-files/my-default.cnf /etc/mysql.cnf
echo "basedir=/usr/local/mysql56" >>/etc/mysql.cnf
echo "datadir=/usr/local/mysql56/data/" >>/etc/mysql.cnf
echo "port=3306" >>/etc/mysql.cnf
echo "user=mysql" >>/etc/mysql.cnf
cp support-files/mysql.server /etc/init.d/mysqld
sed -i "s#^basedir=.*#basedir=/usr/local/mysql56#g" /etc/init.d/mysqld
sed -i "s#^datadir=.*#datadir=/usr/local/mysql56/data/#g" /etc/init.d/mysqld
chown -R root.root /usr/local/mysql56
chown -R mysql. /usr/local/mysql56/data
/etc/init.d/mysqld start
netstat -tulnp | grep 3306


添加到服务启动项里面:

3、php的安装:

下载:

wget -c http://cn2.php.net/distributions/php-5.6.36.tar.gz  (php5)

wget -c http://cn2.php.net/distributions/php-7.2.5.tar.gz   (php7)

解压:

 tar -xvf php-5.6.36.tar.gz

 tar -xvf php-7.2.5.tar.gz

进入到解压后的目录里面去:

cd php-5.6.36
运行:make clean 命令
添加用户:useradd -M php-fpm -s /sbin/nologin
生成配制文件:
./configure --prefix=/usr/local/php5-fpm --with-config-file-path=/usr/local/php5-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm  --with-mysql=/usr/local/mysql56 --with-pdo-mysql=/usr/local/mysql56 --with-mysqli=/usr/local/mysql56/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock  --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-ftp --with-curl --with-pear  --enable-exif
若遇到错误就安装需要依赖的模块如:
yum install libcurl libcurl-devel  -y
编译安装:make && make install
对配制文件进行配制:
cp /home/nfyx/source/php-5.6.36/php.ini-production /usr/local/php5-fpm/etc/php.ini
配制:
 /usr/local/php5-fpm/etc/ php-fpm.conf 
加入以下代码:

[global]
pid = /usr/local/php5-fpm/var/run/php-fpm.pid
error_log = /usr/local/php5-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024


配制文件语法检查:
/usr/local/php5-fpm/sbin/php-fpm -t

对启动文件进行设置:
cp /home/nfyx/source/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
更改权限:chmod 755 /etc/init.d/php-fpm
启动:/etc/init.d/php-fpm start

添加到服务启动项:chkconfig --add /etc/init.d/php-fpm
查看服务:ps aux |grep php-fpm

图例:

编译前配制:


 /usr/local/php5-fpm/etc/ php-fpm.conf r的配制:

 

语法检查、启动、查看

 

4、nginx:
官网:www.nginx.org

下载:wget -c  http://nginx.org/download/nginx-1.14.0.tar.gz
解压:tar -zxvf nginx-1.14.0.tar.gz
进入:cd nginx-1.14.6
生成配制文件:./configure --prefix=/usr/local/nginx
编译安装:make && make install