Lnmp架构搭建+创建Discuz论坛
PHP,一个嵌套的缩写名称,是英文超级文本预处理语言(PHP:Hypertext Preprocessor)的缩写。PHP 是一种 HTML 内嵌式的语言,PHP与微软的ASP颇有几分相似,都是一种在服务器端执行的嵌入HTML文档的脚本语言,语言的风格有类似于C语言,现在被很多的网站编程人员广泛的运用。
PHP 独特的语法混合了C、Java、Perl 以及 PHP 自创新的语法。它可以比 CGI 或者 Perl 更快速的执行动态网页。
LNMP的简介:
LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器。Mysql是一个小型关系型数据库管理系统。PHP是一种在服务器端执行的嵌入HTML文档的脚本语言。这四种软件均为免费开源软件,组合到一起,成为一个免费、高效、扩展性强的网站服务系统。
LNMP的特点:
Nginx是一个小巧而高效的Linux下的Web服务器软件,是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler 站点开发的,已经在一些俄罗斯的大型网站上运行多年,相当的稳定。Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。
LNMP的优点:
1.作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率。
2.作为负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP,也可以支持作为 HTTP代理服务器对外进行服务。Nginx 用C编写,不论是系统资源开销还是CPU使用效率都比Perlbal要好的多。
3.作为邮件代理服务器:Nginx同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也是作为邮件代理服务器),Last/fm 描述了成功并且美妙的使用经验。
4.Nginx 安装非常的简单:配置文件非常简洁(还能够支持perl语法)。Nginx支持平滑加载新的配置,还能够在不间断服务的情况下进行软件版本的升级。
Part3:嵌入HTML中的脚本语言———PHP
1.PHP源码编译
yum install -y re2c-0.13.5-1.el6.x86_64.rpm gd-devel-2.0.35-11.el6.x86_64.rpm yum install -y net-snmp-devel curl-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel gmp-devel openldap-devel -y ##安装软件包,解决必要的依赖性 tar jxf php-5.6.19.tar.bz2 cd php-5.6.19
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --with-openssl=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir -without-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx ##对即将开始安装的PHP进行配置,检验当前的环境是否满足安装PHP的依赖关系 make ##编译 make install ##安装 [root@server2 etc]# php --version ##查看PHP版本 PHP 5.3.3 (cli) (built: Aug 19 2013 05:50:20) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies vim ~/.bash_profile ##设置环境变量 PATH=$PATH:$HOME/bin:/usr/local/lnmp/nginx/sbin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/php/bin export PATH source ~/.bash_profile ##生效 chmod 755 /usr/local/lnmp/mysql/data/ cd /usr/local/lnmp/php/etc cp php-fpm.conf.default php-fpm.conf vim php.ini [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Asia/Shanghai ##更改时区为:亚洲/上海 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock mysqli.default_socket = /usr/local/lnmp/mysql/data/mysql.sock vim /usr/local/lnmp/php/etc/php-fpm.conf [global] ; Pid file ; Note: the default prefix is /usr/local/lnmp/php/var ; Default Value: none pid = run/php-fpm.pid cd php-5.6.19/sapi/fpm/ cp init.d.php-fpm /etc/init.d/fpm chmod +x /etc/init.d/fpm ##加执行权限 /etc/init.d/fpm start ##启动fpm netstat -antple ##查看网络端口,看9000端口是否打开 如图:
vim /usr/local/lnmp/nginx/html/index.php <?php phpinfo() ?> ##查看PHP信息 vim /usr/local/lnmp/nginx/conf/nginx.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.php index.html index.htm; } location /status { stub_status on; access_log off; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; } nginx -t ##检验语法 nginx -s reload ##重新加载Nginx
访问网页http://server2.example.com/,如图:
访问网页http://server2.example.com/status,如图:
2.整合Nginx,MSQL,PHP搭建Lnmp架构,创建Discuz论坛
Crossday Discuz! Board(简称 Discuz!)是北京康盛新创科技有限责任公司推出的一套通用的社区论坛软件系统。自2001年6月面世以来,Discuz!已拥有11年以上的应用历史和200多万网站用户案例,是全球成熟度最高、覆盖率最大的论坛软件系统之一。目前最新版本Discuz! X2.5正式版于2012年4月7日发布,首次引入应用中心的开发模式。2010年8月23日,康盛创想与腾讯达成收购协议,成为腾讯的全资子公司。
Discuz!适用于以下的应用领域:
对稳定性和负载能力要求较高的门户网站 大中型企业的客户在线调查、技术与产品服务 企事业单位内部交流与沟通,办公协作与自动化(OA) 大中专院校的学生、教工与校友讨论区 已经发展到一定规模,具有相当访问量的个人网站 商业、交友、科技、影音、下载等等方面的专门网站 地×××府、电信公司或爱好者建立的地域性讨论区 以上仅是一些常见应用领域的举例,事实上,Discuz! 因其全面的功能设计和可圈点的安全防范,几乎适用于所有需要互动和交流功能的网站,尤其是已经具备相当规模,且经常因为服务器资源耗尽、安全问题或其他原因而损失人气的中大型应用案例。
系统特色
1.卓越的访问速度和负载能力
2.强大而完善的功能
3.国际化和标准化的产品架构
4.周密的安全部署和攻击防护
yum install -y unzip unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/ cd /usr/local/lnmp/nginx/html/ mv upload/ bbs cd bbs/ 登陆http://server2.example.com/bbs,如图:
chmod 777 config/,如图:
chmod 777 -R data/ ,如图:
chmod 777 -R uc_* ,如图:
[root@server2 bbs]# mysql -p Enter password: GAOfang123+++ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.11 Source distribution 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. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> create database discuz; ##创建名为discuz的数据库 Query OK, 1 row affected (0.00 sec) mysql> grant all on discuz.* to gf@localhost identified by 'GAOfang123+++'; ##将discuz的所有权限赋给普通用户gf,并提供密码验证GAOfang123+++ Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> quit Bye [root@server2 bbs]# mysql -ugf -pGAOfang123+++ discuz ##用新用户登陆discuz数据库 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.11 Source distribution 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. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | discuz | +--------------------+ 2 rows in set (0.00 sec) mysql> quit Bye 登陆网页http://server2.example.com/bbs,依次安装数据库,如图:
安装完毕即可进入discuz论坛,如图: