--配置nginx程序执行环境变量
# echo "export PATH=/usr/local/nginx/sbin:$PATH" > /etc/profile.d/nginx.sh
# . /etc/profile.d/nginx.sh
--配置nginx语法着色
# mkdir .vim
# cp -ra /usr/src/nginx-1.11.3/contrib/vim/* .vim/
而后就可以启动服务并测试了:
# service nginx start
以上为LNMP架构nginx配置过程。
二、安装MySQL-5.5.28
1、准备数据存放的文件系统
新建一个逻辑卷,并将其挂载至特定目录即可。过程如下:
--新建大小为20G的分区为LVM
# fdisk -l /dev/sda | grep sda3
/dev/sda3 7675 10286 20976471 8e Linux LVM
--新建物理逻辑卷
# pvcreate /dev/sda3
--新建逻辑卷组
# vgcreate myvg /dev/sda3
--新建大小为15G的逻辑卷
# lvcreate -L 15G -n mydata myvg
# mke2fs -t ext4 /dev/myvg/mydata
这里假设其逻辑卷的挂载目录为/mydata,而后需要创建/mydata/data目录做为mysql数据的存放目录。
# mkdir /mydata
# vim /etc/fstab
/dev/myvg/mydata /mydata ext4 defaults,acl 0 0
# mount -a
# mkdir /mydata/data
2、新建用户以安全方式运行进程:
# groupadd -r mysql
# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
# mkdir /mydata/binlogs
# chown -R mysql:mysql /mydata/data/
# chown -R mysql:mysql /mydata/binlogs
3.安装编译代码需要的包
# yum -y install ncurses-devel cmake
# rpm -ivh bison-devel-2.4.1-5.el6.x86_64.rpm
4、安装并初始化mysql-5.6.32
# tar xf mysql-5.6.32.tar.gz
# cd mysql-5.6.32
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/mydata/data \
> -DSYSCONFDIR=/etc \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DWITH_SSL=system \
> -DWITH_ZLIB=system \
> -DWITH_LIBWRAP=0 \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci
# make && make install
5、授予mysql程序目录权限:
# cd /usr/local/mysql/
# chown -R :mysql /usr/local/mysql/
6、初始化mysql数据基本目录及库文件
# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
7、为mysql提供主配置文件
# cp support-files/my-default.cnf /etc/my.cnf
# vim /etc/my.cnf
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 2
datadir = /mydata/data
innodb_file_per_table = on
binlog_format=mixed
log-bin=/mydata/binlogs/mysql-binlog
server-id = 1
8、为mysql提供SysV init脚本:
# cp support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
9、配置mysql常用环境变量
--配置mysql程序执行环境变量
# echo "export PATH=/usr/local/mysql/bin/:$PATH" > /etc/profile.d/mysql.sh
# . /etc/profile.d/mysql.sh
10、提供man手册至man命令的查找路径
# vim/etc/man.config --加入下行内容
MANPATH /usr/local/mysql/man
11、输出mysql的头文件至系统头文件路径
# ln -sv /usr/local/mysql/include /usr/include/mysql
12、输出MariaDB的库文件给系统的查找路径
# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
# ldconfig
# ldconfig -v | grep mysql
以上为mysql编译安装过程
三、编译安装php-5.6.18
1、解决依赖关系
# yum -y install pcre-devel openssl-devel libxml2-devel bzip2-devel
# yum -y install php-gd freetype-devel libjpeg-devel libpng-devel
# yum -y install libmcrypt-2.5.8-9.el6.x86_64.rpm
# yum -y install libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
# yum -y install mhash-0.9.9.9-3.el6.x86_64.rpm
# yum -y install mhash-devel-0.9.9.9-3.el6.x86_64.rpm
# yum -y install libcurl-devel
2、编译安装
# tar xf php-5.6.18.tar.gz
# cd php-5.6.18
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir
# make -j 4 && make install
3、为php提供配置文件
# cp php.ini-production /usr/local/php/etc/php.ini
# vim /usr/local/php/etc/php.ini
date.timezone = Asia/Shanghai
4、为php-fpm提供Sysv init脚本,并将其添加至服务列表:
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
5、为php-fpm提供配置文件:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
6、编辑php-fpm的配置文件:
# vim /usr/local/php/etc/php-fpm.conf
配置fpm的相关选项为你所需要的值,并启用pid文件(如下最后一行):