LNMP环境搭建(php-5.6.19 nginx-1.9.12 mysql-5.6.19)配置
Nginx
nginx-1.9.12.tar.gz 编译安装
[[email protected]]# tar zxvf nginx-1.9.12.tar.gz
[[email protected]]# cd nginx-1.9.12
[[email protected]]# yum install gcc openssl-devel pcre-develzlib-devel wget -y
[[email protected]]#./configure --user=www --group=www --prefix=/usr/local/nginx--with-http_stub_status_module --with-http_ssl_module
[[email protected]]# make && make install
[[email protected]]# ./sbin/nginx 启动服务器
[[email protected]]#ps –ef | grep nginx
php
php-5.6.19.tar.gz编译安装
[[email protected]]#tar zxvf php-5.6.19.tar.gz
[[email protected]]#cd php-5.6.19
[[email protected]]#yum install libxml2-devel openssl-devel bzip2-devel libmcrypt-devel–y
[[email protected]]#./configure --prefix=/usr/local/php--with-config-file-path=/etc --enable-fpm --enable-cli --enable-pcntl --enable-sockets --enable-opcache --enable-sysvsem--enable-sysvmsg --enable-sysvshm --enable-shmop --enable-zip--enable-ftp --disable-rpath --disable-debug--with-pcre-regex --with-mcrypt --enable-xml--with-openssl --with-imap-ssl --enable-soap--with-iconv --with-curl --disable-fileinfo --with-xmlrpc --with-mhash --with-gd --with-freetype-dir--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr--disable-rpath --enable-bcmath --enable-inline-optimization--enable-mbregex --enable-mbstring --enable-gd-native-ttf --with-ldap-sasl --enable-pdo--with-pdo-mysql --with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config --with-pear --with-libdir=lib64
[[email protected] php-5.6.19]#make
[[email protected] php-5.6.19]#make install
[[email protected] php-5.6.19]# cpphp.ini-production /etc/php.ini 配置文件拷贝
[[email protected] php-5.6.19]# cpsapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm 启动文件拷贝
[[email protected] php-5.6.19]# chmod +x/etc/rc.d/init.d/php-fpm 设置权限
[[email protected] php-5.6.19]# chkconfig --addphp-fpm
[[email protected] php-5.6.19]# chkconfigphp-fpm on 开机自起
[[email protected] php-5.6.19]# cp /usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
[[email protected] etc]# /etc/init.d/php-fpmstart
[[email protected] etc]# netstat –anpt
Mysql 编译安装
(1)先安装cmake(mysql5.5以后是通过cmake来编译的)
[[email protected]]#tar -zxvf cmake-3.5.0.tar.gz
[[email protected] local]#cd cmake-3.5.0
[[email protected]]#./configure
[[email protected] cmake-3.5.0]# make
[[email protected] cmake-3.5.0]# make install
(2)创建mysql的安装目录及数据库存放目录
[[email protected]]#mkdir -p /usr/local/mysql //安装mysql
[[email protected] local]#mkdir -p /usr/local/mysql/data //存放数据库
(3)创建mysql用户及用户组
[[email protected]]#groupadd mysql
[[email protected] local]#useradd -r -g mysql mysql
(4)安装mysql
[[email protected]]# tar xf mysql-5.6.29.tar.gz
[[email protected] local]# cd mysql-5.6.29
[[email protected]]#yum -y install gcc-c++ make cmakebison-devel ncurses-devel
[[email protected] mysql-5.6.29]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DMYSQL_DATADIR=/usr/local/mysql/data\
-DSYSCONFDIR=/etc\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_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\
-DWITH_PARTITION_STORAGE_ENGINE=1\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DMYSQL_USER=mysql\
-DEXTRA_CHARSETS=all\
-DWITH_DEBUG=0 \
-DWITH_ZLIB=system\
-DWITH_SSL=system
[[email protected] mysql-5.6.29]# make && makeinstall
2.配置
(1)设置目录权限
[[email protected]]# cd /usr/local/mysql
[[email protected] mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql
[[email protected] mysql]# chown -R mysql:mysql data
(3)创建系统数据库的表
[[email protected]]# cd /usr/local/mysql
[[email protected] mysql]# scripts/mysql_install_db --user=mysql
2)
[[email protected]]# cp my.cnf /etc/my.cnf //将mysql的启动服务添加到系统服务中
(4)拷贝启动脚本
[[email protected]]# cp support-files/mysql.server /etc/init.d/mysql //将mysql的启动服务添加到系统服务中
(4)开机自动启动
[[email protected]]# chkconfig mysql on
(5) 启动mysql
[[email protected]]# /etc/init.d/mysql start
(6)检查启动端口
[[email protected]]# netstat -anpt
(7)查看数据库
[[email protected]]# ./bin/mysql
mysql> showdatabases;
(8)环境变量设置
[[email protected]]# vim /etc/profile
加入变量设置
内容最下面
#MYSQL
exportMysql_HOME=/usr/local/mysql
exportPATH=$Mysql_HOME/bin:$PATH
(9)直接进入mysql
[[email protected]]# source /etc/profile
[[email protected]]# mysql
(10)mysql 路径
[[email protected]]# which mysql
(11)设置mysql 密码
[[email protected]]# mysqladmin -uroot -p password '123456'
直接enter