紧接上一篇,废话少说,直接实战。详细内容请参考《编译安装LAMP一》
《MySQL-5.5.38通用二进制安装》
2、安装MySQL
# 创建mysql用户和组 [root@localhost ~]# groupadd -r mysql [root@localhost ~]# useradd -r -g mysql -s /sbin/nologin mysql # 目录规划 [root@localhost ~]# mkdir -pv /mydata/data mkdir: created directory `/mydata' mkdir: created directory `/mydata/data' [root@localhost ~]# chown -R mysql:mysql /mydata/data/ # 解压源码包 [root@localhost lamp]# tar xf mysql-5.5.38-linux2.6-i686.tar.gz -C /usr/local/src [root@localhost lamp]# cd /usr/local/ [root@localhost local]# ln -sv src/mysql-5.5.38-linux2.6-i686 mysql `mysql' -> `src/mysql-5.5.38-linux2.6-i686' # 初始化数据库 [root@localhost local]# cd mysql/ [root@localhost mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mydata/data --user=mysql ## 我在这里报错了 # /usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: # cannot open shared object file: No such file or directory [root@localhost mysql]# yum search libaio Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile ========================================= N/S Matched: libaio ========================================= libaio.i686 : Linux-native asynchronous I/O access library libaio.x86_64 : Linux-native asynchronous I/O access library libaio-devel.i686 : Development files for Linux-native asynchronous I/O access libaio-devel.x86_64 : Development files for Linux-native asynchronous I/O access Name and summary matches only, use "search all" for everything. # [root@localhost mysql]# yum -y install libaio [root@localhost mysql]# chown -R root:root /usr/local/src/mysql-5.5.38-linux2.6-i686/ # 提供配置文件和服务启动脚本 [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chkconfig --add mysqld [root@localhost mysql]# chkconfig mysqld on [root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf # 编辑配置文件 [root@localhost mysql]# vi /etc/my.cnf # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /tmp/mysql.sock # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock pid-file = /mydata/data/mysqld.pid character-set-server = utf8 collation-server = utf8_unicode_ci basedir = /usr/local/mysql datadir = /mydata/data user = mysql skip-name-resolve # 启动mysql服务 [root@localhost ~]# service mysqld start Starting MySQL.. SUCCESS! [root@localhost ~]# netstat -tulpn | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 708/mysqld [root@localhost ~]# vi /etc/profile.d/mysql.sh export PATH=$PATH:/usr/local/mysql/bin [root@localhost ~]# . /etc/profile.d/mysql.sh [root@localhost ~]# /usr/local/mysql/bin/mysql_secure_installation [root@localhost ~]# vim /etc/man.config MANPATH /usr/local/mysql/man [root@localhost ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql `/usr/include/mysql' -> `/usr/local/mysql/include/' [root@localhost ~]# vi /etc/ld.so.conf.d/mysql.conf /usr/local/mysql/lib [root@localhost ~]# /sbin/ldconfig # 使用TCMalloc为MySQL加速 [root@localhost lib]# pwd /usr/local/mysql/lib [root@localhost lib]# ls | grep libtcmalloc libtcmalloc_minimal.so libtcmalloc_minimal.so.0 # 编辑mysqld_safe文件 [root@localhost bin]# vi /usr/local/mysql/bin/mysqld_safe # 再# executing mysqld_safe行之后,添加下面这一行 export LD_PRELOAD="/usr/local/mysql/lib/libtcmalloc_minimal.so" # 重启mysql服务 [root@localhost ~]# service mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL... SUCCESS! [root@localhost bin]# lsof -n | grep -i tcma mysqld 4793 mysql mem REG 8,2 888700 14655 /usr/local/src/mysql-5.5.38-linux2.6-i686/lib/libtcmalloc_minimal.so
3、编译安装PHP,以模块方式整合
如果我们先前没有安装: libxml2 libxml2-devel bzip2-devel libmcrypt libmcrypt-devel,则需要安装这些包:
[root@localhost ~]# yum -y install libxml2 libxml2-devel bzip2-devel libmcrypt libmcrypt-devel
不过,我这边没有libmcrypt*包:
No package libmcrypt available.
No package libmcrypt-devel available.
可以到这个网站下载rpm包:http://rpm.pbone.net/
[root@localhost lamp]# ls lib* libmcrypt-2.5.7-1.2.el6.rf.i686.rpm libmcrypt-devel-2.5.7-1.2.el6.rf.i686.rpm [root@localhost lamp]# rpm -ivh lib* warning: libmcrypt-2.5.7-1.2.el6.rf.i686.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY Preparing... ########################################### [100%] 1:libmcrypt ########################################### [ 50%] 2:libmcrypt-devel ########################################### [100%]
好了, 前期准备好了,就开始安装PHP吧
[root@localhost lamp]# tar xf php-5.4.32.tar.gz -C /usr/local/src [root@localhost lamp]# cd /usr/local/src [root@localhost src]# cd php-5.4.32/ # 需要指定 --enable-fpm 以启用fastCGI,以备后续改为fastCGI模式 [root@localhost php-5.4.32]# ./configure \ --prefix=/usr/local/php --with-mysql=/usr/local/mysql \ --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config \ --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir \ --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets \ --enable-fpm --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt \ --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d \ --with-bz2 --enable-maintainer-zts --enable-fpm [root@localhost php-5.4.32]# make && make install [root@localhost php-5.4.32]# cp php.ini-production /etc/php.ini # 编辑 /etc/php.ini 进行设置提升 PHP 安全性。查找定位到 disable_functions = # 修改成 disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen
4、整合apache和php
编辑 /etc/httpd/httpd.conf配置文件, 定位到 AddType, 添加如下两行
[root@localhost ~]# vi /etc/httpd/httpd.conf AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps # 然后定位到: DirectoryIndex, 添加index.phpDirectoryIndex index.php index.html # 测试 [root@localhost ~]# httpd -t Syntax OK [root@localhost ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message [ OK ] [root@localhost ~]# vi /usr/local/apache/htdocs/index.php
通过浏览器访问,出现下面界面说明OK
5、配置Xcache为PHP提速
详细信息请参考《Xcache为PHP提速》
[root@localhost lamp]# tar xf xcache-3.0.4.tar.gz -C /usr/local/src [root@localhost lamp]# cd /usr/local/src [root@localhost src]# cd xcache-3.0.4/ ### 用本地的解释器探测模块所依赖的版本号/扩展API,生成序列号标记,而后才能产生configure文件,才能编译 [root@localhost xcache-3.0.4]# /usr/local/php/bin/phpize [root@localhost xcache-3.0.4]# ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=/usr/local/php/bin/php-config [root@localhost xcache-3.0.4]# make && make install ## 安装完成后,会提示xcache.so模块的路径, 我们把xcache.so移动到/usr/local/php/include/php/ext目录下,方便管理 # Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/ [root@localhost xcache-3.0.4]# mv /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so /usr/local/php/include/php/ext/ ## 生成Xcache管理员的密码(MD5密文) [root@localhost ~]# echo -n '123456' | md5sum e10adc3949ba59abbe56e057f20f883e ### 整合php和xcache [root@localhost ~]# cd /usr/local/src/xcache-3.0.4/ [root@localhost xcache-3.0.4]# mkdir /etc/php.d/ [root@localhost xcache-3.0.4]# cp xcache.ini /etc/php.d/ [root@localhost ~]# vi /etc/php.d/xcache.ini ### 编辑xcache.ini ##通常仅编辑如下4项即可 extension = xcache.admin.enable_auth = xcache.admin.user = xcache.admin.pass = ##################################### [xcache-common] extension = "/usr/local/php/include/php/ext/xcache.so" ;xcache.so路径 [xcache.admin] xcache.admin.enable_auth = On ;开启验证 xcache.admin.user = "xcache" ;验证名 xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e" ;md5后的验证密码, 亦即echo -n "123456" | md5sum,留空则禁用管理页面. [xcache] xcache.shm_scheme ="mmap" ; 决定 XCache 如何从系统分配共享内存 xcache.size=60M ; 0 禁止, 非 0 则启用缓存器. 请注意您系统所允许的 mmap 最大值. xcache.count =1 ; 指定将 cache 切分成多少块.(cat/proc/cpuinfo |grep -c processor) xcache.slots =8K ; 只是作为 hash 槽个数的参考值, 您可以放心地缓冲超过这个个数的项目. xcache.ttl=0 ; 设置缓冲项目的 Ttl (Time To Live) 值, 0=永不过期. xcache.gc_interval =0 ; 检查过期项目, 回收内存空间的间隔. xcache.var_size=4M xcache.var_count =1 xcache.var_slots =8K ; 同上, 不过用于数据缓冲而不是 opcode 缓冲. xcache.var_ttl=0 ; xcache_(get|set|inc|dec) 等的默认 ttl 值. xcache.var_maxttl=0 ; 最大 ttl 值, 程序无法指定超过这个最大值的 ttl. xcache.var_gc_interval =300 xcache.test =Off xcache.readonly_protection = On ;如果启用了 ReadonlyProtection, 将会略微降低性能, 但是会提高一定的安全系数. 这个选项对于xcache.mmap_path = /dev/zero 无效. xcache.mmap_path ="/tmp/xcache" ;缓存文件,不是目录,需要手动创建 xcache.coredump_directory ="" xcache.cacher =On ;使用/不使用 opcode 缓存器. xcache.size = 0 时无效. xcache.stat=On ;使用 stat() 发现检查脚本更新. xcache.optimizer =Off [xcache.coverager] xcache.coverager =On ;启用代码覆盖信息采集到. 启用后xcache.coveragedump_directory 设置以及xcache_coverager_start/stop/get/clean() 才可以使用. (启用后会对降低影响) xcache.coverager_autostart = On ;每个页面请求自动调用 xcache_coverager_start xcache.coveragedump_directory ="" ## 生成xcache缓存 [root@localhost ~]# touch /tmp/xcache [root@localhost ~]# chmod 777 /tmp/xcache [root@localhost ~]# service httpd restart
可以通过phpinfo来验证PHP是否已经支持 Xcache。
安装Discuz!X
[root@localhost lamp]# unzip Discuz_X3.2_SC_UTF8.zip [root@localhost lamp]# cp -r readme/ /www/ [root@localhost lamp]# cp -r upload/ /www/ [root@localhost lamp]# cp -r utility/ /www/ # 这三个目录全部要copy到网站目录下 # upload目录下所有的文件是我们论坛主程序文件。 # readme目录为产品介绍、授权、安装、升级、转换以及版本更新日志说明 # utility目录为论坛附带工具,包括升级程序。 # upload可以做一个软链接,方便我们管理和维护 [root@localhost www]# ln -sv upload discuz_x3 `discuz_x3' -> `upload' [root@localhost www]# ls -l total 12 lrwxrwxrwx. 1 root root 6 Sep 13 16:15 discuz_x3 -> upload drwxr-xr-x. 2 root root 4096 Sep 13 16:10 readme drwxr-xr-x. 12 root root 4096 Sep 13 16:10 upload drwxr-xr-x. 4 root root 4096 Sep 13 16:10 utility ### 配置虚拟主机,编辑/etc/httpd/httpd.conf ## 注释中心主机 #DocumentRoot "/usr/local/apache/htdocs" ## 开启虚拟主机 # Virtual hosts Include /etc/httpd/extra/httpd-vhosts.conf ########################################### ### 编辑 /etc/httpd/extra/httpd-vhosts.conf,注释掉存在的两个虚拟主机,并新建如下ServerAdmin [email protected] DocumentRoot "/www/discuz_x3" ServerName www.discuz.com ErrorLog logs/discuz-error_log CustomLog logs/discuz-access_log common ## 重启httpd服务 [root@localhost ~]# httpd -t [root@localhost ~]# service httpd restartOptions Indexes FollowSymLinks AllowOverride None Require all granted
然后,通过浏览器访问,即可进入安装界面
第一步,你懂的,不同意也得同意,
检查安装环境,出现好多红叉,怎么办?
参考这篇教程《Discuz!X3全新安装图文教程》
我们需要设置相关目录的文件属性,以便数据文件可以被程序正确读写。将服务器上以下目录、以及该目录下的所有文件属性设置为777。
# 晓得怎么做了,就动手 [root@localhost ~]# cd /www/upload/ [root@localhost upload]# chmod -R 777 config [root@localhost upload]# chmod -R 777 data [root@localhost upload]# chmod -R 777 uc_server/ [root@localhost upload]# chmod -R 777 uc_client/data/cache/ # 如果后期要使用模板,还需要 [root@localhost upload]# chmod -R 777 template
OK,在浏览器上刷新一下,权限检查全部通过,好了继续“下一步”
设置运行环境
进入数据库设置界面,如下图所示
我们指定一个数据库名,会自动在MySQL数据库中创建这个库。(但是我看到其官方站点上的教程,步骤是首先在MySQL数据库中手工创建一个库,然后把库的名字填写在这里,不知道有何差别???)填写好Discuz!X数据库相关信息及管理员信息之后,点击“下一步”,系统会自动安装数据库直至完毕。
点击“马上去装应用”,重新登录后台,选择要安装的应用,安装即可。
OK,到此Discuz!X 论坛就已经安装完毕,更多设置,下一篇继续。
http://www.douban.com/note/241300607/
http://coolnull.com/1293.html
http://blog.chinaunix.net/uid-26963748-id-3267204.html
http://www.vfeelit.com/76.html
http://www.fanli7.net/a/JAVAbiancheng/ANT/20140403/444902.html
http://www.discuz.net/thread-3258186-1-1.html
http://www.linuxidc.com/Linux/2011-04/34621.htm