标签:linux
centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)
第一部分LNMP环境搭建
一、编译安装nginx1.10.3
1、准备
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64
[root@localhost ~]# uname -mx86_64
[root@localhost ~]# groupadd nginx
[root@localhost ~]# useradd nginx -s /sbin/nologin -g nginx -M
[root@localhost ~]# mkdir -p /home/qiu/tools
[root@localhost ~]# mkdir /application
[root@localhost ~]# yum -y install pcre pcre-devel openssl openssl-devel
[root@localhost ~]# rpm -qa install pcre pcre-devel openssl openssl-devel
2、下载、解压nginx
[root@localhost ~]# cd /home/qiu/tools[root@localhost tools]# wget [root@localhost tools]# tar xf nginx-1.10.3.tar.gz[root@localhost tools]# cd nginx-1.10.3/
3、安装nginx
[root@localhost nginx-1.10.3]# ./configure --help
[root@localhost nginx-1.10.3]# ./configure --prefix=/application/nginx-1.10.3 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
[root@localhost nginx-1.10.3]# echo $?
0
[root@localhost nginx-1.10.3]# make
[root@localhost nginx-1.10.3]# echo $?
0
[root@localhost nginx-1.10.3]# make install
[root@localhost nginx-1.10.3]# echo $?
0
[root@localhost nginx-1.10.3]# history
[root@localhost nginx-1.10.3]# ln -s /application/nginx-1.10.3/ /application/nginx
4、开启nginx
[root@localhost nginx-1.10.3]# /application/nginx/sbin/nginx -t
[root@localhost nginx-1.10.3]# /application/nginx/sbin/nginx
[root@localhost nginx-1.10.3]# netstat -luntp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8048/nginx: master [root@localhost nginx-1.10.3]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnginx 8048 root 6u IPv4 56025 0t0 TCP *:http (LISTEN)nginx 8049 nginx 6u IPv4 56025 0t0 TCP *:http (LISTEN)
[root@localhost nginx-1.10.3]# systemctl stop firewalld.service
[root@localhost nginx-1.10.3]# setenforce o
5、测试
二、安装MySQL(二进制方法)
1、准备
[root@localhost tools]# groupadd mysql
[root@localhost tools]# useradd mysql -s /sbin/nologin -g mysql -M
[root@localhost tools]# id mysqluid=1002(mysql) gid=1002(mysql) groups=1002(mysql)
2、下载、验证、解压
[root@localhost ~]# cd /home/qiu/tools/
[root@localhost tools]# wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
[root@localhost tools]# tar xf mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz
[root@localhost tools]# lsmysql-5.5.57-linux-glibc2.12-x86_64 mysql-5.5.57-linux-glibc2.12-x86_64.tar.gz nginx-1.10.3 nginx-1.10.3.tar.gz
[root@localhost tools]# mv mysql-5.5.57-linux-glibc2.12-x86_64 /application/mysql-5.5.57-linux-glibc2.12-x86_64
[root@localhost tools]# cd /application/
[root@localhost application]# lsmysql-5.5.57-linux-glibc2.12-x86_64 nginx nginx-1.10.3
[root@localhost application]# ln -s mysql-5.5.57-linux-glibc2.12-x86_64 mysql
3、安装
[root@localhost tools]# cd /application/mysql
[root@localhost mysql]# chown -R mysql.mysql /application/mysql
[root@localhost tools]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/datacp mysql.server /etc/init.d/mysqld
[root@localhost tools]#chown -R mysql.mysql /application/mysql/
[root@localhost tools]# echo "export PATH=/application/mysql/bin:$PATH" >>/etc/profile
[root@localhost tools]# source /etc/profile
[root@localhost tools]# sed -i ‘s#/usr/local/mysql#/applicaton/mysql#g‘ /etc/init.d/mysqld /application/mysql/bin/mysqld_safe
[root@localhost tools]# /etc/init.d/mysqld start
4、测试
[root@localhost support-files]# ps -ef|grep 3306
mysql 11600 11364 0 02:58 pts/0 00:00:02 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/application/mysql/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/application/mysql/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306root 15899 2659 0 04:24 pts/0 00:00:00 grep --color=auto 3306
[root@localhost support-files]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnginx 8048 root 6u IPv4 56025 0t0 TCP *:http (LISTEN)nginx 8049 nginx 6u IPv4 56025 0t0 TCP *:http (LISTEN)
[root@localhost support-files]# netstat -luntp|grep mysqltcp
0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 11600/mysqld
[root@localhost support-files]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.5.57 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
三、fastcgi方式安装php
1、准备
[root@localhost support-files]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) [root@localhost support-files]# uname -aLinux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost support-files]# uname -r
3.10.0-514.el7.x86_64
[root@localhost support-files]# uname -m
x86_64
[root@localhost support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[root@localhost support-files]# yum -y install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[root@localhost support-files]# rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
[root@localhost support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
[root@localhost support-files]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
[root@localhost support-files]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
安装biconv库[root@localhost support-files]# cd /home/qiu/tools/
[root@localhost tools]# wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[root@localhost tools]# tar zvxf libiconv-1.15.tar.gz
[root@localhost tools]# cd libiconv-1.15/
[root@localhost tlibiconv-1.15]# ./configure --prefix=/usr/local/libiconv
[root@localhost tlibiconv-1.15]# make[root@localhost libiconv-1.15]# make install[root@localhost libiconv-1.15]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost libiconv-1.15]# yum -y install libmcrypt-devel
[root@localhost libiconv-1.15]# yum -y install mhash[root@localhost libiconv-1.15]# yum -y install mcrypt
2、下载
[root@localhost /]# cd /home/qiu/tools/
[root@localhost tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
[root@localhost tools]# tar zxf php-5.5.32.tar.gz [root@localhost tools]# cd php-5.5.32
3、安装
./configure \
--prefix=/application/php-5.5.32 \
--with-mysql=/application/mysql \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--enable-ftp \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-opcache=yes
make
make install
[root@localhost php]# cd /home/qiu/tools/php-5.5.32/
[root@localhost php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[root@localhost php-5.5.32]# cd /application/php/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
4、测试
[root@localhost etc]# /application/php/sbin/php-fpm
[root@localhost etc]# ps -rf|grep php-fpm
[root@localhost etc]# ps -ef|grep php-fpm
root 44740 1 0 08:46 ? 00:00:00 php-fpm: master process (/application/php-5.5.32/etc/php-fpm.conf)nginx 44741 44740 0 08:46 ? 00:00:00 php-fpm: pool wwwnginx 44742 44740 0 08:46 ? 00:00:00 php-fpm: pool wwwroot 44747 2659 0 08:46 pts/0 00:00:00 grep --color=auto php-fpm
[root@localhost etc]# lsof -i:9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEphp-fpm 44740 root 7u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)php-fpm 44741 nginx 0u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)php-fpm 44742 nginx 0u IPv4 251732 0t0 TCP localhost:cslistener (LISTEN)[root@localhost etc]# netstat -luntp|grep php-fpmtcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 44740/php-fpm: mast
第二部分LAMP环境搭建
第三部分tomcat+jdk+mysql环境搭建
本文出自 “doublelinux” 博客,谢绝转载!
centos搭建LNMP+LAMP环境+(jdk+tomcat+mysql)
标签:linux
原文地址:http://doublelinux.blog.51cto.com/12300166/1952834