安装php
下载和解压
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar -zxvf php-5.6.30.tar.gz
进入解压后php目录
cd php-5.6.30
编译和make
#编译
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm -with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-libmcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-tty --enable-ftp --enable-mbstring --enable-exif--with-pear --with-curl --with-openssl
#make
make && make install
编译php所遇到的错误及解决方法
1.error: xml2-config not found. Please check your libxml2 installation.
解决:
yum install -y libxml2-devel
2.error: Cannot find OpenSSL's <evp.h>
解决:
yum install -y openssl-devel
3.error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解决:
yum install -y libcurl-devel
4.error: jpeglib.h not found.
解决:
yum install -y libjpeg-turbo-devel
5.error: png.h not found.
解决:
yum install -y libpng-devel
6.error: freetype-config not found.
解决:
yum install -y freetype-devel
7.error: Cannot find MySQL header files under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
解决:
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
tar -zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
拷贝配置文件
cp php.ini-production /usr/local/php-fpm/etc/php.ini
拷贝启动脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#赋予权限
chmod 755 /etc/init.d/php-fpm
进入 /usr/local/php-fpm/etc/下,创建php-fpm.conf
vim php-fpm.conf
[global]
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
#listen = /tmp/php-fcgi.sock
listen = 127.0.0.1:9000
listen.mode = 666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
把php-fpm加入服务列表及开机启动
chkconfig --add php-fpm
chkconfig php-fpm on
启动php
#启动
service php-fpm start
Starting php-fpm [02-Oct-2017 18:17:39] ERROR: [pool www] cannot get uid for user 'php-fpm'
[02-Oct-2017 18:17:39] ERROR: FPM initialization failed
failed
说明:启动报错,需要创建php-fpm用户
#创建php-fpm用户
useradd php-fpm
#重新启动就成功了
service php-fpm start
安装nginx
下载和解压nginx
wget http://nginx.org/download/nginx-1.12.1.tar.gz
tar -zxvf nginx-1.12.1.tar.gz
编译和make
#进入nginx目录
cd nginx-1.12.1
#编译
./configure --prefix=/usr/local/nginx
#make
make && make install
给nginx创建启动脚本
vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
#设置权限
chmod 755 /etc/init.d/nginx
自定义nginx.conf
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 6000;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 3526;
server_names_hash_max_size 4096;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 8 4k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /data/www/discuz;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/discuz$fastcgi_script_name;
}
}
}
把nginx加入服务列表及开机启动
chkconfig --add nginx
chkconfig nginx on
安装discuz
安装准备
#创建安装目录
mkdir -p /data/www/discuz
#进入目录
cd /data/www/discuz
#下载安装包
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
#解压
unzip Discuz_X3.2_SC_UTF8.zip
#将安装文件移动到指定目录
mv upload/* ./
#删除无关文件
rm -rf readme upload utility Discuz_X3.2_SC_UTF8.zip
#根据readme.txt文件提示执行如下操作
chmod 777 -R data config uc_client uc_server
开始安装
浏览器访问discuz安装目录所对应的站点 discuz.com (执行该操作前将域名和IP加入本地hosts),然后根据浏览器中的提示进行后续操作。
检查安装环境
说明:环境检查;目录、文件权限检查;函数依赖性检查,需所有显示打钩,说明没问题,执行下一步.
设置运行环境
说明:第一次安装所以需要选择全新安装
数据库设置
#登录Mysql
mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#创建discuz库
mysql> create database discuz;
Query OK, 1 row affected (0.00 sec)
#创建discuz用户和设置密码,以及来源IP
mysql> grant all on discuz.* to 'discuz'@'192.168.2.157' identified by '123456';
Query OK, 0 rows affected (0.05 sec)
mysql> quit
Bye
数据库配置
说明:只需填写红色框框圈起来的地方,其余保持默认,点击下一步完成安装
显示已经安装成功
说明: 使用刚刚设置的管理员用户名和密码登录即可(管理员用户名:admin 密码:123456)