- [root@localhost ~]# getenforce
- Enforcing
- [root@localhost ~]# setenforce 0
- [root@localhost ~]# getenforce
- Permissive
- //当然。这里也需要到vim /etc/selinux/config将其中的SELINUX=enforcing替换为SELINUX=permissive
- [root@localhost src]# ls
- apr-1.4.6.tar.bz2 apr-util-1.4.1.tar.bz2 httpd-2.4.3.tar.bz2
- [root@localhost src]# tar xf apr-1.4.6.tar.bz2
- [root@localhost src]# cd apr-1.4.6
- [root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr // prefix指定路径
- [root@localhost apr-1.4.6] # make && make install //这里稍微简略了下步骤
- //这个时候,apr已经安装好了 。然后去安装apr-util
- [root@localhost apr-1.4.6]# cd ..
- [root@localhost src]# tar xf apr-util-1.4.1.tar.bz2
- [root@localhost src]# cd apr-util-1.4.1
- [root@localhost apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr //-with-apr告诉其apr的路径
- [root@localhost apr-util-1.4.1]# make
- [root@localhost apr-util-1.4.1]# make install
- [root@localhost apr-util-1.4.1]# cd ..
- [root@localhost src]# yum install pcre-devel
- [root@localhost src]# tar xf httpd-2.4.3.tar.bz2
- [root@localhost src]# cd httpd-2.4.3
- [root@localhost httpd-2.4.3]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=event //mpm=even默认使用event
- [root@localhost httpd-2.4.3]# make
- [root@localhost httpd-2.4.3]# make install
- [root@localhost src]# vim /etc/httpd/httpd.conf
- //添加如下内容
- PidFile "/var/run/httpd.pid"
- [root@localhost src]# cd /etc/rc.d/init.d/
- [root@localhost init.d]# vim httpd
- //添加如下内容
- #!/bin/bash
- #
- # httpd Startup script for the Apache HTTP Server
- #
- # chkconfig: - 85 15
- # description: Apache is a World Wide Web server. It is used to serve \
- # HTML files and CGI.
- # processname: httpd
- # config: /etc/httpd/conf/httpd.conf
- # config: /etc/sysconfig/httpd
- # pidfile: /var/run/httpd.pid
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/httpd ]; then
- . /etc/sysconfig/httpd
- fi
- # Start httpd in the C locale by default.
- HTTPD_LANG=${HTTPD_LANG-"C"}
- # This will prevent initlog from swallowing up a pass-phrase prompt if
- # mod_ssl needs a pass-phrase from the user.
- INITLOG_ARGS=""
- # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
- # with the thread-based "worker" MPM; BE WARNED that some modules may not
- # work correctly with a thread-based MPM; notably PHP will refuse to start.
- # Path to the apachectl script, server binary, and short-form for messages.
- apachectl=/usr/local/apache/bin/apachectl
- httpd=${HTTPD-/usr/local/apache/bin/httpd}
- prog=httpd
- pidfile=${PIDFILE-/var/run/httpd.pid}
- lockfile=${LOCKFILE-/var/lock/subsys/httpd}
- RETVAL=0
- start() {
- echo -n $"Starting $prog: "
- LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch ${lockfile}
- return $RETVAL
- }
- stop() {
- echo -n $"Stopping $prog: "
- killproc -p ${pidfile} -d 10 $httpd
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
- }
- reload() {
- echo -n $"Reloading $prog: "
- if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
- RETVAL=$?
- echo $"not reloading due to configuration syntax error"
- failure $"not reloading $httpd due to configuration syntax error"
- else
- killproc -p ${pidfile} $httpd -HUP
- RETVAL=$?
- fi
- echo
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p ${pidfile} $httpd
- RETVAL=$?
- ;;
- restart)
- stop
- start
- ;;
- condrestart)
- if [ -f ${pidfile} ] ; then
- stop
- start
- fi
- ;;
- reload)
- reload
- ;;
- graceful|help|configtest|fullstatus)
- $apachectl $@
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
- exit 1
- esac
- exit $RETVAL
- //而后为此脚本赋予执行权限:
- [root@localhost init.d]# chmod +x httpd
- [root@localhost init.d]# chkconfig --level 35 httpd on //设定运行级别
- [root@localhost init.d]# chkconfig --list httpd
- httpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
- //下面的步骤可忽略,这里只是可以设置为bash可以直接执行
- [root@localhost init.d]# vim /etv/profile.d/httpd.sh
- //添加
- #/bin/bash
- export PATH=$PATH:/usr/local/apache/bin
- [root@localhost init.d]# export PATH=$PATH:/usr/local/apache/bin
- [root@localhost init.d]# fdisk /dev/sda
- //其中过程省略。。
- [root@localhost init.d]# partprobe /dev/sda
- //创建逻辑卷
- [root@localhost init.d]# pvcreate /dev/sda5
- Writing physical volume data to disk "/dev/sda5"
- Physical volume "/dev/sda5" successfully created
- [root@localhost init.d]# vgcreate myvg /dev/sda5
- Volume group "myvg" successfully created
- [root@localhost init.d]# lvcreate -n mydata -L 5G myvg
- Logical volume "mydata" created
- [root@localhost init.d]# lvs
- LV VG Attr LSize Origin Snap% Move Log Copy% Convert
- mydata myvg -wi-a- 5.00G
- lvtext vgtext -wi-a- 1.00G
- home vol0 -wi-ao 4.88G
- root vol0 -wi-ao 29.28G
- [root@localhost init.d]# mke2fs -j /dev/myvg/mydata
- //设置开机挂载
- [root@localhost ~]# mkdir /mydata
- [root@localhost ~]# vim /etc/fstab
- //添加如下内容
- /dev/myvg/mydata /mydata ext3 defaults 0 0
- [root@localhost ~]# mount –a //重新挂载
- [root@localhost ~]# mkdir /mydata/data //作为数据的挂载目录
- //创建用户
- [root@localhost ~]# groupadd -r mysql
- [root@localhost ~]# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
- [root@localhost ~]# chown -R mysql:mysql /mydata/data
- [root@localhost ~]# cd /usr/local/src/
- [root@localhost src]# tar xf mysql-5.5.28-linux2.6-i686.tar.gz
- [root@localhost src]# cd ..
- [root@localhost local]# pwd
- /usr/local
- [root@localhost local]# ln -sv /usr/local/src/mysql-5.5.28-linux2.6-i686 mysql
- create symbolic link `mysql' to `/usr/local/src/mysql-5.5.28-linux2.6-i686'
- [root@localhost local]# cd mysql
- [root@localhost mysql]# chown -R mysql:mysql .
- [root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
- Installing MySQL system tables...
- [root@localhost mysql]#
- [root@localhost mysql]# cp support-files/my-large.cnf /etc/my.cnf
- [root@localhost mysql]# vim /etc/my.cnf
- //并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:
- thread_concurrency = 2
- //另外还需要添加如下行指定mysql数据文件的存放位置:
- datadir = /mydata/data //添加此行指定mysql数据文件的存放位置
- [root@localhost mysql]# pwd
- /usr/local/mysql
- [root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- [root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld
- //添加至服务列表:
- [root@localhost mysql]# chkconfig --add mysqld
- [root@localhost mysql]# chkconfig mysqld on
- 而后就可以启动服务测试使用了。
- [root@localhost mysql]# vim /etc/man.config
- #####################mysql#############
- MANPATH /usr/local/mysql/man
- 这可以通过简单的创建链接实现:
- [root@localhost mysql]# ln -sv /usr/local/mysql/include /usr/include/mysql
- create symbolic link `/usr/include/mysql' to `/usr/local/mysql/include'
- [root@localhost ld.so.conf.d]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
- [root@localhost ld.so.conf.d]# vim /etc/profile //需要重读或重启或重新登录
- PATH=$PATH:/usr/local/mysql/bin
- //另外export PATH=$PATH:/usr/local/mysql/bin 也可以起到上边的效果
- PS:这个时候。就可以进入数据库创建表之类的东西了!
- 请配置好yum源(可以是本地系统光盘)后执行如下命令:
- [root@localhost ~]# yum -y groupinstall "X Software Development"
- 如果想让编译的php支持mcrypt扩展,此处还需要下载如下两个rpm包并安装之:
- libmcrypt-2.5.7-5.el5.i386.rpm
- libmcrypt-devel-2.5.7-5.el5.i386.rpm
- mhash-0.9.2-6.el5.i386
- mhash-devel-0.9.2-6.el5.i386
- 将下载好的安装包放到linux的src中(过程同上)
- [root@localhost src]# tar xf php-5.4.13.tar.bz2
- [root@localhost php-5.4.13]# ./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 --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
- //说明:
- --prefix=/usr/local/php:php安装路径
- --with-mysql=/usr/local/mysql:mysql安装路径
- --with-openssl:支持openssl功能
- --with-mysqli=/usr/local/mysql/bin/mysql_config:mysql与apache访问的另一种接口,安装在二进制目录下
- --enable-mbstring:多字节string
- --with-freetype-dir:安装的字体库头文件
- --with-jpeg-dir:jpeg类型的库
- --with-png-dir:png类型的库
- --with-zlib:互联网上通用压缩库,先压缩再传送,减少带宽
- --with-libxml-dir=/usr:xml库文件的路径
- --enable-xml:支持xml功能
- --enable-sockets:php支持套接字功能 --with-apxs2=/usr/local/apache/bin/apxs:基于apxs实现让php编译成apache模块
- --with-mcrypt:支持额外的加密库
- --with-config-file-path=/etc:php配置文件放置路径
- --with-config-file-scan-dir=/etc/php.d :php配置文件的分段文件放置路径
- --with-bz2 :压缩库
- --enable-maintainer-zts:当apache使用worker或event这两个MPM,编译时使用该选项
- [root@localhost php-5.4.13]# make
- [root@localhost php-5.4.13]# make test
- [root@localhost php-5.4.13]# make install
- 为php提供配置文件:
- [root@localhost php-5.4.13]# cp php.ini-production /etc/php.ini
- //php包中提供了配置文件,把配置文件重命名为/etc/php.ini,php的配置文件后缀名是以.ini结尾
- [root@localhost php-5.4.8]# vim /etc/httpd/httpd.conf
- 1、添加如下二行
- AddType application/x-httpd-php .php
- AddType application/x-httpd-php-source .phps
- //能够让APACHE处理PHP结尾的文件
- 2、定位至DirectoryIndex index.html
- 修改为:
- DirectoryIndex index.php index.html
- //能让目录索引处理php结尾的页面文件。在配置文件中可以根据自己安装内容启动相对模块。比如:SSL模块等。
- [root@localhost php-5.4.13]#cd /usr/local/apache/htdocs/ //进入apache页面目录下,把默认页面修改为php页面文件
- [root@localhost php-5.4.13]#mv index.html index.php
- [root@localhost php-5.4.13]#vim index.php
- <html><body><h1>It works! doubao’s test page</h1></body></html>
- <?php
- phpinfo();
- ?>
- :wq
- //保存退出
- [root@localhost htdocs]# service httpd restart //重启
- //发起php页面测试
- //生成的测试页面内容对我们还是会有帮助,可以留意一下里面的内容
- <html><body><h1>It works! my test page</h1></body></html>
- <?php
- $conn=mysql_connect('localhost','root','');
- if ($conn)
- echo "<h2>Success...</h2>";
- else
- echo "<h2>Failure...</h2>";
- phpinfo();
- ?>
- //保存退出然后
- [root@localhost htdocs]# service httpd restart //重启网络服务
- [root@localhost ~]# vim /etc/httpd/httpd.conf #指定网页存放目录
- #DocumentRoot "/usr/local/apache/htdocs"
- DocumentRoot "/www/a.org"
- #<Directory "/usr/local/apache/htdocs">
- <Directory "/www/a.org">
- [root@localhost discuz]# cd /usr/local/src/discuz/
- [root@localhost discuz]# unzip Discuz_X2.5_SC_GBK.zip #解压软件包
- [root@localhost discuz]# mv ./upload/* /www/a.org/ #将解压后的文件放到网页目录中
- [root@localhost discuz]# mysqladmin -uroot -p password 'redhat' #为数据库添加密码
- 登录数据库为root用户添加远程权限
- mysql> grant all privileges on *.* to root@'%' identified by 'redhat';
- Query OK, 0 rows affected (0.30 sec)
- [root@localhost discuz]# cd /www/a.org/
- [root@localhost a.org]# mkdir ./config/config_global.php
- [root@localhost a.org]# mkdir ./config/config_ucenter.php
- [root@localhost a.org]# chmod o+rw ./config/*
- [root@localhost a.org]# chmod o+rw ./data
- [root@localhost a.org]# chmod o+rw ./data/cache
- [root@localhost a.org]# chmod o+rw ./data/avatar
- [root@localhost a.org]# chmod o+rw ./data/plugindata
- [root@localhost a.org]# chmod o+rw ./data/download
- [root@localhost a.org]# chmod o+rw ./data/addonmd5
- [root@localhost a.org]# chmod o+rw ./data/template
- [root@localhost a.org]# chmod o+rw ./data/threadcache
- [root@localhost a.org]# chmod o+rw ./data/p_w_upload
- [root@localhost a.org]# chmod o+rw ./data/p_w_upload/album
- [root@localhost a.org]# chmod o+rw ./data/p_w_upload/forum
- [root@localhost a.org]# chmod o+rw ./data/p_w_upload/group
- [root@localhost a.org]# chmod o+rw ./data/log
- [root@localhost a.org]# chmod o+rw ./uc_client/data/cache
- [root@localhost a.org]# chmod o+rw ./uc_server/data
- [root@localhost a.org]# chmod o+rw ./uc_server/data/cache
- [root@localhost a.org]# chmod o+rw ./uc_server/data/avatar
- [root@localhost a.org]# chmod o+rw ./uc_server/data/backup
- [root@localhost a.org]# chmod o+rw ./uc_server/data/logs
- [root@localhost a.org]# chmod o+rw ./uc_server/data/tmp
- [root@localhost a.org]# chmod o+rw ./uc_server/data/view
- ./configure --prefix=/usr/local/php --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --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
- [root@localhost config]# service portmap status
- portmap (pid 2958) is running...
- //查看下此服务是否在运行中,因为NFS服务要在这个服务的基础上才能开启
- [root@localhost config]# service nfs start //开始NFS服务
- Starting NFS services: [ OK ]
- Starting NFS quotas: [ OK ]
- Starting NFS daemon: [ OK ]
- Starting NFS mountd: [ OK ]
- PS:这个时候可以# rpcinfo -p localhost 查看所有rpc进程所监听的端口
- [root@localhost config]# vim /etc/exports
- /www/a.org 172.16.0.0/16(rw,no_root_squash)
- ###no_root_squash: 不将root用户映射为来宾账户为了让虚拟机2可以读写
- :wq
- [root@localhost config]# exportfs –ra
- //切记!!!要重新导出!!!
- [root@localhost htdocs]# mount -t nfs 172.16.111.1:/www/a.org /usr/local/apache/htdocs/
- ###客户端使用mount命令挂载
- 当然这里也可以将其设为开机自动挂在:
- [root@localhost htdocs]# vim /etc/fstab
- 172.16.111.1:/www/a.org /usr/local/apache/htdocs nfs defaults,_rnetdev 0 0
- #######_rnetdev:设置开机自动挂载时,能挂载就挂载,不能挂载就算了
PS:这是本人参考本人好友的博文后自己重新编写的过程。本人重新做了3次,基本排除了过程中遇到的细微的错误,也尽量减免了很多不必要的步骤,请大家放心试验。如果本文再重新出现了其他的错误欢迎留言讨论。我好友的博文地址我也给贴出来吧:http://yhwhzhang.blog.51cto.com/3821405/1183900。