环境介绍:
centos6.4
LNMP搭建IP:10.10.54.59
//安装nginx
1.下载并安装
##解压nginx-1.4.5.tar.gz
[root@xiao59 softs]# tar xvf nginx-1.4.5.tar.gz
##安装依赖软件包
[root@xiao59 softs]yum install -y pcre-devel openssl-devel
2.编译
##切换到编译目录
[root@xiao59 softs]# cd nginx-1.4.5
[root@xiao59 nginx-1.4.5]# ./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --user=apache --group=apache --with-http_ssl_module --with-http_gzip_static_module
make && make install
3.启动服务
[root@xiao59 ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
***************************************************************************************
//安装mysql
1.下载并安装
##解压
tar xvf mysql-5.5.30.tar.gz
2.编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/dbdata \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=yes
make && make install
##清除缓存:rm CMakeCache.txt
安装:yum install bison.x86_64(开始没安装,导致初始化数据库一直出错)
3.创建目录
mkdir -p /data/dbdata
chown mysql.mysql /data/dbdata/ -R
4.复制mysql配置文件my.cnf
cp /softs/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf
5.复制启动脚本
cp /softs/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
6.初始化数据库文件
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/dbdata
7.添加环境变量
vim /etc/profile
=============================
PATH=${PATH}:/usr/local/mysql/bin
===========================
8.在mysql中创建用户
mysql> grant all on *.* to 'xiaoq'@'10.10.54.%' identified by '322815';
mysql> flush privileges;
******************************************************************************
//安装php
我们使用nginx调用php的时候使用fpm的方式,在php5.4中加入了对php-fpm的支持,所以就不需要打补丁了。
1.下载并安装
##解压
tar xvf php-5.4.25.tar.gz
##切换目录
cd php-5.4.25
#建立php安装目录
mkdir -p /usr/local/php5
mkdir /usr/local/php5/etc
2.编译参数解析
===================================================================
--prefix=PREFIX install architecture-independent files in PREFIX [/usr/local]
--with-config-file-path=PATH Set the path in which to look for php.ini [PREFIX/lib]
--with-mysql=DIR Include MySQL support. DIR is the MySQL base directory
--with-mysql-sock=SOCKPATH MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
--with-mysqli=FILE Include MySQLi support. FILE is the path to mysql_config.
--with-zlib=DIR Include ZLIB support (requires zlib >= 1.0.9)
--disable-rpath Disable passing additional runtime library search paths
--enable-bcmath Enable bc style precision math functions
--enable-shmop Enable shmop support
--enable-sysvsem Enable System V semaphore support
--with-curl=DIR Include cURL support
--with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
--with-curlwrappers EXPERIMENTAL: Use cURL for url streams
--enable-fpm Enable building of the fpm SAPI executable
--with-mcrypt=DIR Include mcrypt support
--with-gd=DIR Include GD support. DIR is the GD library base
--with-openssl=DIR Include OpenSSL support (requires OpenSSL >= 0.9.6)
--with-mhash=DIR Include mhash support
--enable-sockets Enable sockets support
--with-ldap=DIR Include LDAP support
--with-ldap-sasl=DIR LDAP: Include Cyrus SASL support
--with-xmlrpc=DIR Include XMLRPC-EPI support
--enable-zip Include Zip read/write support
--enable-soap Enable SOAP support
==================================================================
//扩展:
CGI方式安装才用的参数:
--enable-fpm --打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序
##PHP5.4以后默认加载下列参数
--enable-fastcgi --支持fastcgi方式启动PHP
--enable-force-CGI-redirect --重定向方式启动PHP
--with-ncurses --支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库
--enable-pcntl freeTDS需要用到的,可能是链接mssql 才用到
mhash和mcrypt算法的扩展
--with-mcrypt 算法
--with-mhash 算法
以上函数库需要安装
3.安装依赖软件
1)yum install -y zlib.x86_64 zlib-devel.x86_64 openssl.x86_64 openssl-devel.x86_64
2)下载安装:wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
##解压
tar xvf libmcrypt-2.5.7.tar.gz
##编译
./configure && make && make install
3)下载wget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
##解压
[root@xiao59 softs]# tar xvf mhash-0.9.9.9.tar.gz
##编译
./configure && make && make install
4.编译
1)./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock --with-iconv-dir=/usr/local/ --with-zlib --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
编译错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
安装:yum install libxml2-devel.x86_64
编译错误:
configure: error: png.h not found.
安装:yum install libpng-devel.x86_64
编译错误:
configure: error: Cannot find ldap libraries in /usr/lib.
解决方法:
##查找
[root@xiao59 php-5.4.25]# whereis libldap
libldap: /usr/lib64/libldap.so
[root@xiao59 php-5.4.25]#ls -lh /usr/lib64/libldap*
##创建软连接
[root@xiao59 php-5.4.25]# ln -s /usr/lib64/libldap* /usr/lib
##动态加载:ldconfig
2)make
make: *** [ext/phar/phar.php] Error 127
解决方法:
ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
##动态加载:ldconfig
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
解决方法:/usr/local/webserver/php5/bin/php go-pear.php
也可以./configure时附加--without-pear
3)make install
5.复制php配置文件到安装目录
[root@xiao59 php-5.4.25]# cp php.ini-production /usr/local/php5/etc/php.ini
6.删除系统自带的配置文件
rm -rf /etc/php.ini
7.创建配置文件软链接
ln -s /usr/local/php5/etc/php.ini /etc/php.ini
8.启动
[root@xiao59 php-5.4.25]# /usr/local/php5/sbin/php-fpm
[12-Mar-2014 21:13:17] ERROR: failed to open configuration file '/usr/local/php5/etc/php-fpm.conf': No such file or directory
[12-Mar-2014 21:13:17] ERROR: failed to load configuration file '/usr/local/php5/etc/php-fpm.conf'
[12-Mar-2014 21:13:17] ERROR: FPM initialization failed
解决方法:
[root@xiao59 php-5.4.25]# find / -name 'php-fpm.conf'
/softs/php-5.4.25/sapi/fpm/php-fpm.conf
##创建连接:ln -s /softs/php-5.4.25/sapi/fpm/php-fpm.conf /usr/local/php5/etc/php-fpm.conf
##动态加载:ldconfig
//可以加载到启动目录
[root@xiao59 ~]# cp /softs/php-5.4.25/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@xiao59 ~]# chmod +x /etc/init.d/php-fpm
[root@xiao59 ~]# chkconfig --add php-fpm
*******************************************************
//配置nginx支持php
1.创建PHP配置文件
[root@xiao59 ~]# mv /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
2.配置php-fpm.conf
[root@xiao59 ~]# vim /usr/local/php5/etc/php-fpm.conf
======================================================
pid = run/php-fpm.pid
user = apache
group = apache
listen = 127.0.0.1:9000
======================================================
3.配置nginx.conf
vim /usr/local/nginx/conf/nginx.conf
=========================================================
http {
server {
listen 80;
server_name localhost;
charset utf-8;
access_log logs/host.access.log main;
root /var/www/hr;
index index.html index.htm index.php;
##去掉注释,添加目录
location ~ \.php$ {
root /var/www/hr;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/hr/$fastcgi_script_name;
include fastcgi_params;
}
}
=========================================================
2.重启服务
[root@xiao59 ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@xiao59 ~]# /etc/init.d/mysqld restart
3.建立测试网页
[root@xiao59 ~]# vim /var/www/hr/index.php
================================================
<?php
phpinfo();
?>
==================================================
4.添加dns解析
[root@xiao59 ~]# vim /var/named/named.ssr.com
==============================================
$TTL 86400
@ IN SOA ssr.com. root (2014010802 1H 15M 1W 1D)
@ IN NS ssr.com.
ssr.com. IN A 10.10.54.59
www.ssr.com. IN A 10.10.54.59
hr.ssr.com. IN A 10.10.54.59
bbs.ssr.com. IN A 10.10.54.59
====================================================
##重启:[root@xiao59 ~]# /etc/init.d/named restart
5.下载解压工具并解压
[root@xiao59 ~]# yum install unzip.x86_64
[root@xiao59 hr]# unzip Discuz_X3.0_SC_UTF8.zip
//测试
##在浏览器中输入
10.10.54.59 --显示PHP Version 5.4.2页面
10.10.54.59/upload --显示安装向导页面
同意之后,显示目录或文件权限错误
[root@xiao59 ~]# chown apache.apache /var/www/hr/ -R
然后下一步。
==============================================
数据库服务器:10.10.54.59
数据库名:ultrax
数据库用户名:xiaoq
数据库密码:322815
数据表前缀:pre_ --同一数据库运行多个论坛时,请修改前缀
系统信箱 Email:admin@admin.com --用于发送程序错误报告
管理员账号:admin
管理员密码:
重复密码:
管理员 Email:wangxq@ssr.com
===========================================================
转载于:https://my.oschina.net/xiaoq6427/blog/208868