Centos 6.3 + Nginx + PHP-FPM + MySQL+phpMyAdmin 安装 Discuz

| 2019-05-17

实操部分:完整安装

一、安装软件:

wget http://www.atomicorp.com/installers/atomic.sh ;  #下载最新的CentOS源。
chmod 755 atomic.sh
./atomic.sh                      #安装YUM源
yum check-update            #更新yum软件包

yum -y install nginx mysql-server php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap  php-bcmath php-xmlrpc php-fpm memcached php-pecl-memcache 

yum -y update   #系统更新
reboot              #重启 Centos 6.3

二、配置软件

1、配置nginx支持php
vi /etc/nginx/conf.d/default.conf    #开启php支持,添加index.php
location / {
       root  /usr/share/nginx/html;
        index index.php index.html index.html
    }
location ~ \.php$ {                                    #取消FastCGI server部分的location注释
         root           /usr/share/nginx/html;      #网站根目录。
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  script_FILENAME  /usr/share/nginx/html$fastcgi_script_name;  
          include     fastcgi_params;
}

2、配置php-fpm
vi /etc/php-fpm.d/www.conf
user = nginx 
group = nginx

3、配置mysql 
service mysqld start
mysql_secure_installation  #设置root账户密码 , 修改mysql安全:全部按4次 Y

4、安装配置phpMyAdmin,使用 yum install phpMyAdmin,安装2.112版本,其他版本安装方法如下:

cd /usr/share/nginx
wget http://oss.aliyuncs.com/aliyunecs/onekey/phpMyAdmin-4.1.8-all-languages.zip
unzip phpMyAdmin-4.1.8-all-languages.zip
mv phpMyAdmin-4.1.8-all-languages phpMyAdmin
cp -rf phpMyAdmin /usr/share/nginx/html
chown -R nginx.nginx /usr/share/nginx/html/phpMyAdmin 
cd /usr/share/nginx/html/phpMyAdmin
vi config.sample.inc.php                                                  #按Esc, Shift+: ,wq 回车,进行保存。
$cfg['Servers'][$i]['auth_type'] = 'http';                            #修改 cookie 部分内容并保存

chown root.nginx /var/lib/php/session                              #修改文件夹权限root.nginx,默认为root.apache                         
service nginx restart
http://www.sumask.com/phpMyAdmin                             #打开phpMyAdmin,输入mysql  root 及密码。

5、安装vsftp

#yum -y install vsftpd      #使用yum命令安装vsftp
#useradd -d /usr/share/nginx/html -s /sbin/nologin pwftpd
#passwd pwftpd

修改/etc/vsftpd/vsftpd.conf
#vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO

重新启动vsftpd
#service vsftpd restart 

6、开启服务并重启系统

chkconfig nginx on
chkconfig mysqld on
chkconfig php-fpm on
chkconfig memcached on

service nginx restart
service mysqld restart
service php-fpm restart
service memcached start

7、安装Discuz X3.2, 开启 memcache 内存优化

vi /etc/nginx/conf.d/default.conf    #开启php支持
location / {
       root  /usr/share/nginx/html;
        index index.php index.html index.html
    }

location ~ \.php$ {                         
           root           /usr/share/nginx/html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  script_FILENAME   /usr/share/nginx/html$fastcgi_script_name; 
           include     fastcgi_params;
}

cd /usr/share/nginx/
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
unzip Discuz_X3.2_SC_UTF8.zip
cp -rf upload/* /usr/share/nginx/html                    #复制 upload 文件到 html 
chown -R nginx.nginx /usr/share/nginx/html          #设置目录所有者   nginx.nginx    

service nginx restart
http://www.sumask.com/install/index.php             #访问你的Discuz网站


#开启Discuz X3.2 的 memcache 内存优化,修改config_global.php的内容

vim  /usr/share/nginx/html/config/config_global.php   
                   
$_config['memory']['memcache']['server'] = 'localhost';


 
#开启Discuz伪静态rewrite,在default.conf文件中server{} 段的最后面添加以下rewrite 内容:

vi /etc/nginx/conf.d/default.conf
  1.                                    
  2. rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
  3. rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
  4. rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  5. rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
  6. rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  7. rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
  8. rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
  9. rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
  10. rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
  11. if (!-e $request_filename) {
  12.         return 404;
  13. }
  14.  
复制代码
理论部分:Centos 6.3 yum安装 CentOS + Nginx + PHP-FPM + MySQL

wget http://www.atomicorp.com/installers/atomic.sh   #最新的CentOS源。
chmod 755 atomic.sh
./atomic.sh                      #安装YUM源
yum check-update            #更新yum软件包

一、安装nginx
yum install nginx
service nginx start
chkconfig nginx on

二、安装mysql
yum install mysql mysql-server mysql-devel

service mysqld start
chkconfig mysqld on

三、安装php
#安装PHP及组件,使PHP支持 MySQL、PHP支持FastCGI模式
yum -y install nginx mysql-server php php-mysql php-gd libjpeg* php-pear php-xml php-mbstring php-mcrypt php-mhash libmcrypt libmcrypt-devel php-imap php-ldap  php-bcmath php-xmlrpc php-fpm memcached php-pecl-memcache 

service mysqld restart
service nginx restart
service php-fpm start
chkconfig php-fpm on

四、安装Memcache

1. 安装Memcache 
yum install memcached
2.启动Memcache  #discuz X3.1 内存优化
memcached -u root -d -m 64 -l 127.0.0.1 -p 11211   #监听ip最好还是设置下,毕竟这玩意儿没任何验证的,用netstat -ln命令查看,发现11211端口已经打开 
3.安装PHP的memcache扩展,生成一个memcache.so文件。
yum install php-pecl-memcache   
service memcached start
chkconfig memcached on

五、安装apc

yum -y install php-pecl-apc

六、其他测试,memcache Discuz X3.2内存优化

cd /usr/share/nginx/html/
vi memcache.php                   #建一个 memcache.php 测试页
i                                          
< ?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$version = $memcache->getVersion();
echo "Server's version: ".$version."
\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)
\n";
$get_result = $memcache->get('key');
echo "Data from the cache:
\n";
var_dump($get_result);
?>
esc
:wq!
chown nginx.nginx memcache.php

编辑:航网科技 来源:深圳航网科技有限公司 本文版权归原作者所有 转载请注明出处

在线客服

微信扫一扫咨询客服


全国免费服务热线
0755-36300002

返回顶部