Mysql----二进制安装:
下载rpm包
创建MySQL用户:
useradd -s /sbin/nologin mysql -M
这里遇到无法创建用户,提示:useradd: group mysql exists - if you want to add this user to
解决方法参考:https://www.linuxidc.com/Linux/2012-03/56175.htm
id mysql
解压安装包:
tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz
移动文件之application目录中,创建软链接
数据库初始化:
查看数据库:
修改启动文件 位置:/application/mysql/bin/mysqld_safe
初始化配置文件/etc/my.cnf
设置环境变量:
可以直接用mysql 访问Mysql数据库
安全配置
设置密码:mysqladmin -u root password '123456'
修改密码 :mysqladmin -uroot -p123456 password 911216
查看状态:netstat -lntup|grep mysql
设置永久启动:chkconfig --add mysqld
小结:
步骤:
FastCGI、PHP:
检查环境:
php程序在开发及运行时会调用一些如zlib、gd等函数库,因此确认lib库是否已经安装。执行以下命令:
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
注:libjpeg-turbo-devel是早期的libjpeg-devel的新名,libcurl=devel是早期的curl-devel的新名
安装需要的lib:
yum install zlib-devel libxml2-devel libjpeg-turbo-devel libiconv-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y
安装完成后记得检查
yum源没有libiconv-devel包 需要手动安装
第一种方法
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make insatall
PHP相关扩展库
第三方yum源:wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel mhash mcrypt
PHP服务开始安装:
cn.php.net
下载包:wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
解压:tar xf php-5.5.32.tar.gz
cd php-5.5.32
编译参数:
./configure \
--prefix=/application/php5.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-repath \
--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-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-usr=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
./configure --prefix=/application/php5.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-repath --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-soap --enable-short-tags --enable-static --with-xsl --with-fpm-usr=www --with-fpm-group=www --enable-ftp --enable-opcache=no
解决configure、make会出现的问题:
ln -s /aplication/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar
make 编译
make install 编译安装
ln -s /application/php5.5.32/ /application/php
配置文件
cp php.ini-production /application/php/lib/php.ini
cp php-fpm.conf.default php-fpm.conf
/application/php/sbin/php-fpm
cd /application/php/etc
配置location(nginx+php)
重启nginx
www目录下:echo "<?php phpinfo(); ?>" >test_info.php
cat test_info.php
配置mysql+php连接测试:
www目录下:
到这里:LNMP环境组合搭建完成。