大纲

一、编译安装Apache

二、安装MysqL数据库

三、编译安装PHP

四、整合Apache与PHP

五、安装Xcache加速器

六、启用服务器状态

七、PHP连接MysqL测试

八、安装discuz论坛(discuz_X3.0_SC_GBK)

注:所有软件版本 CentOS6.4+httpd2.4.4+MysqL5.6.12+PHP5.4.16+xcache3.03 都是目前最新(所有的安装包点击这里下载)

一、编译安装Apache

1. 安装前准备

修改yum源(163)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[root@web ~] # yum install wget
[root@web ~] # wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
--2013-06-29 18:39:02-- http: //mirrors .163.com/.help /CentOS6-Base-163 .repo
Resolving mirrors.163.com... 123.58.173.106
Connecting to mirrors.163.com|123.58.173.106|:80... connected.
HTTP request sent,awaiting response... 200 OK
Length: 2006 (2.0K) [application /octet-stream ]
Saving to: a?CentOS6-Base-163.repo?
100%[================>] 2,006 --.-K /s in 0s
2013-06-29 18:39:02 (152 MB /s ) - a?CentOS6-Base-163.repoa? saved [2006 /2006 ]
[root@web ~] # cd /etc/yum.repos.d/
[root@web yum.repos.d] # mv CentOS-Base.repo CentOS-Base.repo.bak
[root@web yum.repos.d] # mv /root/CentOS6-Base-163.repo CentOS-Base.repo
[root@web yum.repos.d] # ls
CentOS-Base.repo CentOS-Media.repo
CentOS-Base.repo.bak CentOS-Vault.repo
CentOS-Debuginfo.repo
[root@web yum.repos.d] # yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@web yum.repos.d] # yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.7 kB 00:00
base /group_gz | 212 kB 00:00
base /filelists_db | 5.9 MB 00:01
base /primary_db | 4.4 MB 00:01
base /other_db | 2.7 MB 00:00
extras | 3.4 kB 00:00
extras /filelists_db | 10 kB 00:00
extras /prestodelta | 905 B 00:00
extras /primary_db | 18 kB 00:00
extras /other_db | 5.7 kB 00:00
updates | 3.4 kB 00:00
updates /filelists_db | 2.9 MB 00:00
updates /prestodelta | 617 kB 00:02
updates /primary_db | 3.2 MB 00:00
updates /other_db | 419 kB 00:00
Metadata Cache Created
[root@web yum.repos.d] #


安装编译工具

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@web yum.repos.d] #yum groupinstall "Development Tools" "Development Libraries" �y
[root@web yum.repos.d] # yum grouplist
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
Installed Groups:
Development tools
E-mail server
Fonts
General Purpose Desktop
Graphical Administration Tools
Input Methods
Legacy X Window System compatibility
MysqL Database client
Perl Support

关闭SElinux

1
2
3
4
5
6
7
8
9
10
11
12
[root@web ~] # vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@web ~] # reboot

关闭防火墙

1
2
3
4
5
6
7
8
[root@web ~] # service iptables stop
[root@web ~] # service ip6tables stop
[root@web ~] # chkconfig iptables off
[root@web ~] # chkconfig ip6tables off
[root@web ~] # chkconfig iptables --list
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@web ~] # chkconfig ip6tables --list
ip6tables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

修改主机名

1
2
3
4
5
6
7
[root@web ~] # vim /etc/sysconfig/network
NETWORKING= yes
HOSTNAME=web. test .com
~
[root@web ~] # vim /etc/hosts
127.0.0.1 web web. test .com localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


2. 解决依赖关系

httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。

(1). 编译安装apr

1
2
3
4
5
6
[root@web src] # tar xf apr-1.4.6.tar.bz2
[root@web src] # cd apr-1.4.6
[root@web src] # ./configure --help | less (可以查看帮助文件)
[root@web src] # ./configure --prefix=/usr/local/apr (指定安装路径)
[root@web src] # make
[root@web src] # make install


(2). 编译安装apr-util

1
2
3
4
5
6
7
[root@web src] # tar xf apr-util-1.5.2.tar.bz2
[root@web src] # cd apr-util-1.5.2
[root@web src] # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
(--prefix指定安装路径;--with-apr指定apr的安装路径,apr-util依赖于apr)
[root@web src] # make && make install
附:apache官方对APR的介绍:
The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behavIoUr regardless of the platform on which their software is built,relieving them of the need to code special- case conditions to work around or take advantage of platform-specific deficiencies or features.

(3). httpd-2.4.4编译过程也要依赖于pcre-devel软件包,需要事先安装。

1
[root@web ~] # yum install pcre-devel -y

3. 编译安装httpd-2.4.4

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@web src] # tar xf httpd-2.4.4.tar.gz
[root@web src] # cd httpd-2.4.4
[root@web httpd-2.4.4] # ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --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
--sysconfdir= /etc/httpd :指定配置文件安装位置
-- enable -so :支持动态共享模块如果没有这个模块PHP将无法与apache结合工作
-- enable -ssl :启用支持ssl
-- enable -cgi :支持cgi
-- enable -rewrite :支持URL重写
--with-zlib :压缩库,在互联网上传播时可节约带宽
--with-apr= /usr/local/apr :指定apr路径
--with-apr-util= /usr/local/apr-util :指定apr-util路径
-- enable -mpms-shared=all :支持多道处理模块
--with-mpm=event :设定默认的模块

错误:

1
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

解决方法:

1
[root@web httpd-2.4.4] # yum install -y openssl-devel

补充说明:

(1)构建MPM为静态模块
在 全部平台中,MPM都可以构建为静态模块。在构建时选择一种MPM,链接到服务器中。如果要改变MPM,必须重新构建。为了使用指定的MPM,请在执行 configure脚本 时,使用参数 --with-mpm=NAME。NAME是指定的MPM名称。编译完成后,可以使用 httpd -l 来确定选择的MPM。 此命令会列出编译到服务器程序中的所有模块,包括 MPM。

(2)构建 MPM 为动态模块
在 Unix或类似平台中,MPM可以构建为动态模块,与其它动态模块一样在运行时加载。 构建 MPM 为动态模块允许通过修改LoadModule指令内容来改变MPM,而不用重新构建服务器程序。在执行configure脚本时,使用--enable- mpms-shared选项即可启用此特性。当给出的参数为all时,所有此平台支持的MPM模块都会被安装。还可以在参数中给出模块列表。默认MPM, 可以自动选择或者在执行configure脚本时通过--with-mpm选项来指定,然后出现在生成的服务器配置文件中。编辑LoadModule指令 内容可以选择不同的MPM。

4. 修改httpd的主配置文件,设置其Pid文件的路径

说明:手动编译安装后,httpd.pid文件是存放在/usr/local/apache/logs/目录下的,这个位置未免有些不方便。

更改配置文件

1
2
3
4
5
6
[root@web httpd-2.4.4] # cd
[root@web ~] # cd /etc/httpd/
[root@web httpd] # ls
conf conf.d extra httpd.conf logs magic mime.types modules original run
[root@web httpd] # cp httpd.conf httpd.conf.bak
[root@web httpd] # vim httpd.conf

#在配置文件中找一个位置定义一下Pid文件路径就可以了

1
Pidfile "/var/run/httpd.pid"

5. 提供SysV服务脚本/etc/rc.d/init.d/httpd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[root@web httpd] # vim /etc/init.d/httpd
#!/bin/bash
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
. /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 # -----指定apachectl程序位置
httpd=${HTTPD- /usr/local/apache/bin/httpd } #-------httpd程序位置
prog=httpd
pidfile=${PIDFILE- /var/run/httpd .pid} #----如果文件存在就使用存在文件路径,如果不存在就使用/var/rum/httpd.pid
lockfile=${LOCKFILE- /var/lock/subsys/httpd } # --------创建的锁文件
RETVAL=0
start() {
echo -n $ "Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS #----以$pidfile文件执行httpd 并且使用选项start
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@web httpd]# chmod +x /etc/init.d/httpd #添加执行权限

#设置开机自启动

1
2
3
4
5
[root@web httpd] # chkconfig httpd --add
[root@web httpd] # chkconfig httpd on
[root@web httpd] # chkconfig httpd --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web httpd] #

6. 启动apache并测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@web httpd] # service httpd start
Starting httpd: AH00558: httpd: Could not reliably determine the server 's fully qualified domain name,using web.test.com. Set the ' ServerName' directive globally to suppress this message
[ OK ]
[root@web httpd] #
[root@web httpd] # netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID /Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 990 /sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1066 /master
tcp 0 0 :::80 :::* LISTEN 36920 /httpd
tcp 0 0 :::22 :::* LISTEN 990 /sshd
tcp 0 0 ::1:25 :::* LISTEN 1066 /master
udp 0 0 0.0.0.0:68 0.0.0.0:* 890 /dhclient
[root@web httpd] #

启动成功了,但似乎有警告,我们看一下!

1
Starting httpd: AH00558: httpd: Could not reliably determine the server 's fully qualified domain name,using web.test.com. Set the ' ServerName' directive globally to suppress this message

解决方案:

编辑httpd.conf文件,搜索"/ServerName",添加ServerName localhost:80

1
2
3
4
5
6
[root@web httpd] # vim /etc/httpd/httpd.conf
再重新启动apache 即可。
[root@web httpd] # service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@web httpd] #

好了问题解决,下面我们用Windows 7访问一下!效果如下:

效果图1

好了测试成功,下面我们继续!

7. 为httpd服务的相关命令添加环境变量

1
2
3
[root@web httpd] # httpd
- bash : httpd: command not found
[root@web httpd] #

大 家看到了,虽然我们可以使用 service httpd restart 来重新启动Apache,是我们无法使用httpd命令,下面我们就来解决一下!直接在/etc/profile.d目录下创建的httpd.sh环境变 量文件,因为在默认的情况下这个目录下定义的环境变量都是profile文件的组成部分。

1
2
3
4
5
6
[root@web httpd] # vim /etc/profile.d/httpd.sh
export PATH=$PATH: /usr/local/apache/bin
[root@web httpd] # source /etc/profile #重新读取一下环境变量
[root@web httpd] # httpd �t #测试一下
Syntax OK
[root@web httpd] #

现在httpd服务的相关命令就可以直接使用了,嘿嘿!

二、安装MysqL数据库

1. 准备数据存放的文件系统

说明:新建一个逻辑卷,并将其挂载至特定目录即可。这里假设其逻辑卷的挂载目录为/mydata,而后需要创建/mydata/data目录做为MysqL数据的存放目录。

(1). 先确认下系统里是否有LVM工具,默认没有安装

1
2
[root@web httpd] # rpm -qa | grep lvm
[root@web httpd] # yum install -y lvm2

(2). 查看一下磁盘

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@web httpd] # fdisk -l
disk /dev/sda : 21.5 GB,21474836480 bytes
255 heads,63 sectors /track ,2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical /physical ): 512 bytes / 512 bytes
I /O size (minimum /optimal ): 512 bytes / 512 bytes
disk identifier: 0x0000a0a2
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1301 10240000 83 Linux
/dev/sda3 1301 1938 5120000 83 Linux
/dev/sda4 1938 2611 5405696 5 Extended
/dev/sda5 1939 2066 1024000 82 Linux swap / Solaris
[root@web httpd] #

(3). 创建逻辑分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[root@web ~] # fdisk /dev/sda
/dev/sda7 2066 2327 2099724 8e Linux LVM #我这里是测试环境就创建了一个2G分区
[root@web ~] # partx -a /dev/sda #告诉内核有关存在和磁盘上的分区的编号
[root@web ~] # pvcreate /dev/sda7 #创建物理卷
Physical volume "/dev/sda7" successfully created
[root@web ~] # vgcreate myvg /dev/sda7 #创建卷组
Volume group "myvg" successfully created
[root@web ~] #
[root@web ~] # lvcreate -n mydata -L 1G myvg #创建一个1G的逻辑卷
Logical volume "mydata" created
[root@web ~] # lvs
LV VG Attr LSize Pool Origin Data% Move Log cpy%sync Convert
mydata myvg -wi-a---- 1.00g
[root@web ~] #
[root@web ~] # mkfs.ext4 /dev/myvg/mydata #格式化
[root@web ~] # mkdir /mydata #创建挂载目录
[root@web ~] # mount /dev/myvg/mydata /mydata/ #挂载
[root@web ~] # vim /etc/fstab
/dev/myvg/mydata /mydata ext4 defaults 0 0 #增加这一行
[root@web ~] # mount �a #测试挂载是否成功
[root@web ~] # mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda3 on /data type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/myvg-mydata on /mydata type ext4 (rw)
[root@web ~] #

(4). 为了便于管理在/mydata目录下再创建个子目录data用于存放数据

1
2
3
4
[root@web ~] # mkdir /mydata/data
[root@web ~] # ls /mydata/
data lost+found
[root@web ~] #

2. 新建用户以安全方式运行进程

1
2
3
[root@web ~] # groupadd -r MysqL
[root@web ~] # useradd -g MysqL -r -s /sbin/nologin -M -d /mydata/data MysqL
[root@web ~] # chown -R MysqL:MysqL /mydata/data

3. 安装并初始化MysqL5.6.12

(1). 说明:MysqL 安装包有三种式,rpm,源码包,二进制包(已编译好,解压后简单配置一下就可以用),我这里用的就是二进制包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@web src] # tar -xf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ #-C指定解压目录
[root@web local ] # ln -sv mysql-5.6.12-linux-glibc2.5-x86_64/ MysqL #创建软链接
`MysqL ' -> `mysql-5.6.12-linux-glibc2.5-x86_64/'
[root@web local ] # cd MysqL
[root@web MysqL] # ls
bin data include lib MysqL- test scripts sql-bench
copYING docs INSTALL-BINARY man README share support-files
[root@web MysqL] #
[root@web MysqL] # chown -R MysqL:MysqL . #更改属主属组
[root@web MysqL] # ll
total 76
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 bin
-rw-r--r-- 1 MysqL MysqL 17987 May 21 23:18 copYING
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 MysqL MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 MysqL MysqL 4096 Jun 29 21:12 man
drwxr-xr-x 10 MysqL MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 MysqL MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 MysqL MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 MysqL MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 MysqL MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 MysqL MysqL 4096 Jun 29 21:12 support-files

(2). 执行MysqL 初始化的data存放位置的准备

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@web MysqL] # scripts/MysqL_install_db --user=MysqL --datadir=/mydata/data #执行MysqL 初始化的data存放位置的准备
Installing MysqL system tables.... /bin/MysqLd : error while loading shared libraries: libaio.so.1: cannot open shared object file : No such file or directory
#初始化时报错说缺少libaio.so我们安装一下
[root@web MysqL] # yum install libaio
[root@web MysqL] # scripts/MysqL_install_db --user=MysqL --datadir=/mydata/data #再次执行MysqL 初始化的data存放位置的准备
To start MysqLd at boot time you have to copy
support-files /MysqL .server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MysqL root USER !
To do so,start the server, then issue the following commands:
. /bin/MysqLadmin -u root password 'new-password'
. /bin/MysqLadmin -u root -h web. test .com password 'new-password'
Alternatively you can run:
. /bin/MysqL_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MysqL daemon with:
cd . ; . /bin/MysqLd_safe &
You can test the MysqL daemon with MysqL- test -run.pl
cd MysqL- test ; perl MysqL- test -run.pl
Please report any problems with the . /bin/MysqLbug script!
The latest information about MysqL is available on the web at
http: //www .MysqL.com
Support MysqL by buying support /licenses at http: //shop .MysqL.com
WARNING: Found existing config file . /my .cnf on the system.
Because this file might be in use,it was not replaced,
but was used in bootstrap (unless you used --defaults- file )
and when you later start the server.
The new default config file was created as . /my-new .cnf,
please compare it with your file and take the changes you need.
WARNING: Default config file /etc/my .cnf exists on the system
This file will be read by default by the MysqL server
If you do not want to use this,either remove it,or use the
--defaults- file argument to MysqLd_safe when starting the server
[root@web MysqL] #
[root@web MysqL] # ls /mydata/data/ #查看 data 目录有文件说明初始化成功
ibdata1 ib_logfile0 ib_logfile1 MysqL performance_schema test

(3). 初始化完成后MysqL中目录文件的属主应改回成root,以免被别人攻破MysqL用户密码而带来数据破坏等

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@web MysqL] # cd /usr/local/MysqL/
[root@web MysqL] # chown root /usr/local/MysqL/* -R
[root@web MysqL] # ll
total 84
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 bin
-rw-r--r-- 1 root MysqL 17987 May 21 23:18 copYING
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 root MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 root MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 support-files
[root@web MysqL] #

4. 为MysqL提供主配置文件

初始化后会自动在当前目录下创建一个my.cnf配置文件,直接修改就可以(在MysqL 5.6 以后配置文件自动生成,不需要我们再进行复制)

(1). 查看配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[root@web MysqL] # ll
total 84
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 bin
-rw-r--r-- 1 root MysqL 17987 May 21 23:18 copYING
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 data
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 docs
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 include
-rw-r--r-- 1 root MysqL 7469 May 21 23:18 INSTALL-BINARY
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 lib
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 man
-rw-r--r-- 1 root root 943 Jun 29 21:18 my.cnf
-rw-r--r-- 1 root root 943 Jun 29 21:23 my-new.cnf
drwxr-xr-x 10 root MysqL 4096 Jun 29 21:12 MysqL- test
-rw-r--r-- 1 root MysqL 2496 May 21 23:18 README
drwxr-xr-x 2 root MysqL 4096 Jun 29 21:12 scripts
drwxr-xr-x 28 root MysqL 4096 Jun 29 21:12 share
drwxr-xr-x 4 root MysqL 4096 Jun 29 21:12 sql-bench
drwxr-xr-x 3 root MysqL 4096 Jun 29 21:12 support-files
[root@web MysqL] #
[root@web MysqL] # cat my.cnf
# For advice on how to change settings please see
# http://dev.MysqL.com/doc/refman/5.6/en/server-configuration-defaults.html
[MysqLd]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MysqL. Start at 70% of total RAM for dedicated server,else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set,remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed,experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@web MysqL] #

大家可以看到生成的配置文件很简单,我们得添加一些内容!

(2). 修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@web MysqL] # vim my.cnf
添加内容是:
binlog- format =ROW
log-bin=master-bin.log
log-slave-updates= true
gtid-mode=on
enforce-gtid-consistency= true
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync -master-info=1
slave-parallel-workers=2
binlog-checksum=CRC32
master-verify-checksum=1
slave-sql-verify-checksum=1
binlog-rows-query-log_events=1
server- id =1
report-port=3306
port=3306
datadir= /mydata/data
socket= /tmp/MysqL .sock
report-host=master. test .com

5. 为MysqL提供sysv服务脚本并启动服务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@web MysqL] # cp support-files/MysqL.server /etc/init.d/MysqLd #复制sysv脚本
[root@web MysqL] # chkconfig --add MysqLd
[root@web MysqL] # chkconfig MysqLd on #开机自启动
[root@web MysqL] # chkconfig MysqLd --list
MysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@web MysqL] # service MysqLd start
Starting MysqL.... SUCCESS!
[root@web MysqL] # netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID /Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 990 /sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1066 /master
tcp 0 0 :::80 :::* LISTEN 37120 /httpd
tcp 0 0 :::22 :::* LISTEN 990 /sshd
tcp 0 0 ::1:25 :::* LISTEN 1066 /master
tcp 0 0 :::3306 :::* LISTEN 37924 /MysqLd #MysqL启动成功
udp 0 0 0.0.0.0:68 0.0.0.0:* 890 /dhclient

6. 输出MysqL的man手册至man命令的查找路径

1
2
[root@web MysqL] # vim /etc/man.config
MANPATH /usr/local/MysqL/man #增加这一行

7. 输出MysqL的头文件至系统头文件路径/usr/include

1
2
3
[root@web MysqL] # ln -sv /usr/local/MysqL/include/ /usr/include/MysqL #输出MysqL的头文件至系统头文件
` /usr/include/MysqL ' -> `/usr/local/MysqL/include/'
[root@web MysqL] # cd /usr/include/MysqL/

8. 输出MysqL的库文件给系统库查找路径

1
2
3
4
5
6
7
8
9
10
[root@web MysqL] # vim /etc/ld.so.conf.d/MysqL.conf
/usr/local/MysqL/lib #直接新建编辑/etc/ld.so.conf.d/MysqL.conf文件,把MysqL的库文件路径添加进去就可以了
~
[root@web MysqL] # ldconfig �v# 让系统重新读取库文件
/usr/local/MysqL/lib :
libtcmalloc_minimal.so.0 -> libtcmalloc_minimal.so (changed)
libMysqLclient.so.18 -> libMysqLclient_r.so.18.0.0
/usr/lib64/MysqL :
libMysqLclient.so.16 -> libMysqLclient.so.16.0.0
libMysqLclient_r.so.16 -> libMysqLclient_r.so.16.0

9. 修改PATH环境变量,让系统可以直接使用MysqL的相关命令

1
2
3
[root@web MysqL] # vim /etc/profile.d/MysqL.sh #添加环境变量(与添加httpd是一样的)
export PATH=$PATH: /usr/local/MysqL/bin
[root@web MysqL] # source /etc/profile #重新读取一下环境变量

10. 测试并连接MysqL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@web MysqL] # MysqL
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.12-log MysqL Community Server (GPL)
copyright (c) 2000,2013,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 |
| test |
+--------------------+
4 rows in set (0.02 sec)
MysqL>

三、编译安装PHP

1. 编译安装PHP-5.4.16

说明:
(1). 这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。
(2). 如果使用PHP5.3以上版本,为了链接MysqL数据库,可以指定MysqLnd,这样在本机就不需要先安装MysqL或MysqL开发包了。 MysqLnd从PHP 5.3开始可用,可以编译时绑定到它(而不用和具体的MysqL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。

1
2
3
4
# ./configure --with-MysqL=MysqLnd --with-pdo-MysqL=MysqLnd --with-MysqLi=MysqLnd
# make
# make test
# make intall


(1). 安装图片资源软件

1
[root@web PHP-5.4.16] # yum -y install gd gd-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel

(2). 安装libxml(扩展标记语言)库

1
[root@web PHP-5.4.16] # yum -y install libxml2 libxml2-devel

(3). 安装bzip2压缩库

1
[root@web PHP-5.4.16] # yum install -y bzip2 bzip2-devel

(4). 安装mcrypt加密库

1
2
3
4
5
6
7
8
9
[root@web src] # rpm -ivh libmcrypt-2.5.8-4.3.x86_64.rpm
warning: libmcrypt-2.5.8-4.3.x86_64.rpm: Header V3 DSA /SHA1 Signature,key ID 04b8b50a: NOKEY
Preparing... ########################################### [100%]
1:libmcrypt ########################################### [100%]
[root@web src] # rpm -ivh libmcrypt-devel-2.5.8-4.3.x86_64.rpm
warning: libmcrypt-devel-2.5.8-4.3.x86_64.rpm: Header V3 DSA /SHA1 Signature,key ID 04b8b50a: NOKEY
Preparing... ########################################### [100%]
1:libmcrypt-devel ########################################### [100%]
[root@web src] #

(5). 编译PHP 5.4.16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[root@web PHP-5.4.16] # tar -xf PHP-5.4.16.tar.gz
[root@web PHP-5.4.16] # cd PHP-5.4.16
[root@web PHP-5.4.16] # ./configure --prefix=/usr/local/PHP --with-MysqL=/usr/local/MysqL --with-openssl --with-MysqLi=/usr/local/MysqL/bin/MysqL_config --enable-mbstring --with-gd --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
--with-MysqL= /usr/local/MysqL :MysqL相关
--with-openssl :让其能够支持openssl功能
--with-MysqLi= /usr/local/MysqL/bin/MysqL_config :MysqL的另外一个接口,让MysqL与PHP交互的接口;接口程序是MysqL_config,是个二进制程序
-- enable -mbstring :多字节string,支持中文或者是非一个字节能够表示的语言
--with-gd : 支持gd库
--with-freetpye- dir :支持freetype功能,freetype:自由的可移植的字体库,可以实现去引用特定字体的
--with-jpeg- dir :支持jpeg图片
--with-png- dir :支持png图片
--with-zlib:互联网上常用的,通用格式的压缩库,让数据文件先压缩再传送给客户端
--with-libxml- dir :xml(扩展标记语言),现在的很多系统在实现数据交互的时候,都要基于xml来实现,所以要PHP支持xml,并且让其知道其库文件所在位置
-- enable -sockets:让PHP支持基于套接字的通信
--with-apxs2:基于apxs实现让PHP编译成apace模块
--with-mcrypt:支持加密功能的,额外的加密库
--with-config- file -path :PHP配置文件的路径放在了什么地方 主配置文件是PHP.ini
--with-config- file -scan :主配置文件的片段,也是配置文件,这个路径下以.ini结尾的都是配置文件片段
--with-bz2 :压缩库
-- enable -maintainer-zts :这一项的使用取决于apache是什么类型的,apache使用的是prefork就不需要;如果使用的是event或者是worker就要添加这一项;apache以线程工作就必须编译这一项
Generating files
configure: creating . /config .status
creating main /internal_functions .c
creating main /internal_functions_cli .c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License,available in this |
| distribution in the file LICENSE. By continuing this installation |
| process,you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license,you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating PHP5.spec
config.status: creating main /build-defs .h
config.status: creating scripts /PHPize
config.status: creating scripts /man1/PHPize .1
config.status: creating scripts /PHP-config
config.status: creating scripts /man1/PHP-config .1
config.status: creating sapi /cli/PHP .1
config.status: creating main /PHP_config .h
config.status: executing default commands
#编译完成
[root@web PHP-5.4.16] # make && make install
Installing PHP SAPI module: apache2handler
/usr/local/apache/build/instdso .sh SH_LIBTOOL= '/usr/local/apr/build-1/libtool' libPHP5.la /usr/local/apache/modules
/usr/local/apr/build-1/libtool --mode= install install libPHP5.la /usr/local/apache/modules/
libtool: install : install .libs /libPHP5 .so /usr/local/apache/modules/libPHP5 .so
libtool: install : install .libs /libPHP5 .lai /usr/local/apache/modules/libPHP5 .la
libtool: install : warning: remember to run `libtool --finish /root/src/PHP-5 .4.16 /libs '
chmod 755 /usr/local/apache/modules/libPHP5 .so
[activating module `PHP5' in /etc/httpd/httpd .conf]
Installing PHP CLI binary: /usr/local/PHP/bin/
Installing PHP CLI man page: /usr/local/PHP/PHP/man/man1/
Installing PHP CGI binary: /usr/local/PHP/bin/
Installing build environment: /usr/local/PHP/lib/PHP/build/
Installing header files: /usr/local/PHP/include/PHP/
Installing helper programs: /usr/local/PHP/bin/
program: PHPize
program: PHP-config
Installing man pages: /usr/local/PHP/PHP/man/man1/
page: PHPize.1
page: PHP-config.1
Installing PEAR environment: /usr/local/PHP/lib/PHP/
[PEAR] Archive_Tar - installed: 1.3.11
[PEAR] Console_Getopt - installed: 1.3.1
warning: pear /PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)
warning: pear /PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
[PEAR] PEAR - installed: 1.9.4
Wrote PEAR system config file at: /usr/local/PHP/etc/pear .conf
You may want to add: /usr/local/PHP/lib/PHP to your PHP.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.1
/root/src/PHP-5 .4.16 /build/shtool install -c ext /phar/phar .phar /usr/local/PHP/bin
ln -s -f /usr/local/PHP/bin/phar .phar /usr/local/PHP/bin/phar
Installing PDO headers: /usr/local/PHP/include/PHP/ext/pdo/
[root@web PHP-5.4.16] #

#安装完成

(6). 为PHP提供配置文件

查看配置文件

1
2
3
4
5
6
7
8
[root@web PHP-5.4.16] # ls | grep PHP.ini
PHP.ini-development
PHP.ini-production
[root@web PHP-5.4.16] #
PHP.ini-development :用于开发环境
PHP.ini-production :用于生产环境:把这项复制到 /etc/ 目录下重命名为PHP.ini即可;不需要启动服务,因为已经编译成Apache模块了;是否启动服务要看工作模型,当做成fastcgi要启动服务
[root@web PHP-5.4.16] # cd PHP-5.4.16
[root@web PHP-5.4.16] # cp PHP.ini-production /etc/PHP.ini

(在编译的时候已经指定了配置文件的路径,所以PHP会自动到/etc/目录下去找其配置文件)

四、整合Apache与PHP

1. 编辑apache配置文件httpd.conf,以apache支持PHP

(1). 首先要在apache配置文件中定义,使apache能够处理PHP结尾的文件,全文查找AddType字段,添加一下内容

1
2
3
4
[root@web PHP-5.4.16] # vim /etc/httpd/httpd.conf
AddType application /x-httpd-PHP .PHP
AddType application /x-httpd-PHP-source .PHPs
PHPIniDir "/usr/local/PHP"

(2). 定位至DirectoryIndex index.html修改为:

1
DirectoryIndex index.PHP index.html


2. 重启apache并测试

1
2
3
4
[root@web PHP-5.4.16] # service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@web PHP-5.4.16] #

3. 增加测试文件

1
2
3
4
[root@web PHP-5.4.16]# vim /usr/local/apache/htdocs/test.PHP
<?
PHPinfo();
?>

4. 测试效果

效果2

5. 问题

在用PHP5.3以上的PHP版本时,只要是涉及时间的会报一个错!

执行PHPinfo();时提示:

1
Warning: PHPinfo(): It is not safe to rely on the system 's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning,you most likely misspelled the timezone identifier. We selected the timezone ' UTC' for Now,but please set date .timezone to select your timezone. in /usr/local/apache/htdocs/test .PHP on line 2

解决办法有三种:

(1). 在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');

1
2
3
4
5
[root@web PHP-5.4.16] # vim /usr/local/apache/htdocs/test.PHP
<?
date_default_timezone_set( "PRC" );
PHPinfo();
?>

(2). 在页头使用 ini_set('date.timezone','Asia/Shanghai');

(3). 修改PHP.ini。打开PHP.ini查找date.timezone 去掉前面的分号修改成为:date.timezone ="PRC" PRC注意加上双引号,要不还会出错!

1
2
[root@web PHP-5.4.16] # vim /etc/PHP.ini
date .timezone = "PRC"

五、安装Xcache加速器

1. 为PHP添加xcache功能

1
2
3
4
5
6
7
8
[root@web src] # tar -xf xcache-3.0.3.tar.gz
[root@web src] # cd xcache-3.0.3
[root@web xcache-3.0.3] # /usr/local/PHP/bin/PHPize
Configuring for :
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
[root@web xcache-3.0.3] #

2. 编译安装Xcache 3.0.3

1
2
3
4
5
[root@web xcache-3.0.3] # ./configure --enable-xcache --with-PHP-config=/usr/local/PHP/bin/PHP-config
[root@web xcache-3.0.3] # make && make install
编译完成,让PHP支持xcache功能前提要把xcache的配置信息添加到PHP的配置文件中
Installing shared extensions: /usr/local/PHP/lib/PHP/extensions/no-debug-zts-20100525/
[root@web xcache-3.0.3] #

3. 编辑PHP.ini,整合PHP和xcache

1
2
3
4
5
6
7
8
9
10
11
[root@web xcache-3.0.3] # mkdir /etc/PHP.d
[root@web xcache-3.0.3] # cp xcache.ini /etc/PHP.d/ #也可以直接把xcache.ini配置信息直接追加到PHP.ini配置文件中
[root@web xcache-3.0.3] # ls /etc/PHP.d/
xcache.ini
[root@web xcache-3.0.3] # vim /etc/PHP.d/xcache.ini #
接下来编辑 /etc/PHP .d /xcache .ini,找到zend_extension开头的行,修改为如下行:
[xcache-common]
;; non-Windows example:
extension = /usr/local/PHP/lib/PHP/extensions/no-debug-zts-20100525/xcache .so #修改这一行
;; Windows example:
; extension = PHP_xcache.dll

4. 重启apache并测试

1
2
3
4
[root@web xcache-3.0.3] # service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@web xcache-3.0.3] #

效果3

说明:测试可以使用windows主机访问linux主机IP,查看PHP.info中是否有xcache模块相关信息

六、启用服务器状态

说明:

mod_status模块可以让管理员查看服务器的执行状态,它通过一个HTML页面展示了当前服务器的统计数据。这些数据通常包括但不限于:
(1) 处于工作状态的worker进程数;
(2) 空闲状态的worker进程数;
(3) 每个worker的状态,包括此worker已经响应的请求数,及由此worker发送的内容的字节数;
(4) 当前服务器总共发送的字节数;
(5) 服务器自上次启动或重启以来至当前的时长;
(6) 平均每秒钟响应的请求数、平均每秒钟发送的字节数、平均每个请求所请求内容的字节数;

启用状态页面的方法很简单,只需要在主配置文件中添加如下内容即可:

1
2
3
4
5
[root@web xcache-3.0.3] # vim /etc/httpd/httpd.conf
<Location /server-status >
SetHandler server-status
Require all granted
< /Location >

需要提醒的是,这里的状态信息不应该被所有人随意访问,因此,应该限制仅允许某些特定地址的客户端查看。比如使用Require ip 172.16.0.0/16来限制仅允许指定网段的主机查看此页面 。

效果图:

效果4

七、PHP连接MysqL测试

(1). 编辑apache的默认页面/usr/local/apache/htdocs/test.PHP

1
2
3
4
5
6
7
8
[root@web xcache-3.0.3] # vim /usr/local/apache/htdocs/test.PHP
<?
$conn=MysqL_connect( 'localhost' , 'root' , '' );
if ($conn)
echo "Success" ;
else
echo "Failure" ;
?>

(2). 测试

效果5

连接成功!

八、安装discuz论坛(discuz_X3.0_SC_GBK最新版)

(1). 授权主机对MysqL的访问

1
2
3
4
MysqL> GRANT ALL PRIVILEGES ON *.* TO 'root' @ '192.168.%.%' IDENTIFIED BY '123456' ;
Query OK,0 rows affected (0.03 sec)
MysqL> FLUSH PRIVILEGES;
Query OK,0 rows affected (0.02 sec)

(2). 准备discuz 3.0

1
2
[root@web src] # unzip discuz_X3.0_SC_GBK.zip
[root@web src] # mv upload/* /usr/local/apache/htdocs/

(3). 安装

1


(4). 修改权限

2

1
2
[root@web htdocs] # chmod 777 ./data ./config/ ./data/cache/ ./data/avatar/ ./data/plugindata/ ./data/download/ ./data/addonmd5/ ./data/template/ ./ data/threadcache/ ./data/attachment/ ./data/attachment/album/ ./data/attachment/forum/ ./data/attachment/group/ ./data/log/ ./uc_client/data/cache/ ./uc_server/data ./uc_server/data/avatar/ ./uc_server/data/backup/ ./uc_server/data/logs/ ./uc_server/data/tmp/ ./uc_server/data/view/ ./uc_server/data/cache/
[root@web htdocs] #

修改后效果如下:

image

(5). 选择全新安装

4


(6). 配置数据库文件

5

(7). 安装完成

6

(8). 最终效果

7


所有演示全部完成 !

CentOS6.4+httpd2.4.4+mysql5.6.12+php5.4.16+xcache3.03(最新LAMP编译安装过程)的更多相关文章

  1. ios – Xcode警告:“没有处理文件的规则”和“找不到目录”

    重命名我的项目文件夹后,我收到以下错误消息:什么可能出错?解决方法关于第一个警告,您可以在项目设置中的“构建阶段”中检查XCode,即头文件不会出现在“编译源”列表中.

  2. 你如何将xcode项目转换为cocoapod?

    我有一段代码,我发现我在多个不同的项目中重复使用,所以我想把它变成一个cocoapod并使用私人cocoapod仓库.我的问题是如何将xcode项目设置为cocoapod?它应该是一个静态库还是一个带有appdelegate的空“项目”?

  3. ios – 如何将文件添加到主包的/ Library / Sounds目录中?

    根据Apple’sdocumentation,/Library/Sounds中的声音文件将在尝试播放声音时由系统搜索.如何将声音文件添加到此文件夹?适用于iOS的正确文档应为here总之,您只需将声音文件作为应用程序包的非本地化资源添加到项目中.

  4. ios – 资产目录与文件夹参考:何时使用其中一个?

    我可以将文件放入Assets.xcassets,或者我可以将文件放入文件夹引用.我何时会选择一个而不是另一个?

  5. ios – 从icloud备份中限制sqlite-wal和sqlite-shm

    我是第一次使用coredata,我必须从文档目录中的iCloud备份限制sqlitedb文件,我使用下面的代码完成了它//阻止iCloud备份文档目录文件夹现在我不明白的是,我们还需要从icloud备份中限制sqlite-wal和sqlite-shm文件,如果是,那么如何从icloud备份限制sqlite-wal和sqlite-shm文件我想要一个解决方案,而无需从文档目录文件夹中更改sqlitedb位置…

  6. iOS:如何从文档目录中删除具有特定扩展名的所有现有文件?

    当我更新我的iOS应用程序时,我想删除Documents目录中的任何现有sqlite数据库.现在,在应用程序更新时,我将数据库从软件包复制到文档目录,并通过附加软件包版本来命名它.因此,在更新时,我还想删除可能存在的任何旧版本.我只是希望能够删除所有sqlite文件,而无需循环浏览并查找以前版本的文件.是否有任何方法可以对removeFileAtPath:方法进行通配符?解决方法那么,你想要删除所有*.sqlite文件?

  7. iOS推送通知适用于Dev而不是Enterprise Distribution

    本网站上没有其他问题,我已经能够找到实际上提出了Dev将工作的原因,但企业分布不会.为什么归档总是使aps环境生产?

  8. .dylib在Debug中链接,在XCode中找不到适用于iPhone的版本

    所以我已经将libxml2.2.dylib库包含在我的iPhoneXCode项目中,以创建一些Xml和XPath解析实用程序.当我编译并运行在模拟器和设备的调试模式时,我没有问题,但是,当我切换到发布模式我得到…

  9. ios – 从文件目录加载UIImage

    我正在尝试从文件目录加载一个UIImage,并将其设置为UIImageView,如下所示:但是,每当我尝试以上,图像从不加载.该图像在Documents/MyAppCustomDirectory/school.png中.以上是否正确从该目录加载?我也尝试了其他几个:UIImageimageWithContentsOfFile,以及基于SO响应的其他方法.解决方法要获取您应该使用的文档目录:我不太清

  10. Xcode 6 / iOS 8模拟器数据和软件包文件夹脚本

    随着xcode6的最新更改,它看起来像.app文件和文档文件夹不再驻留在iPhone模拟器目录中的同一个文件夹中.以前,我们可以访问目录和.app文件但在Xcode6中,模拟器目录是完全不同的:和其中CryptNumber1,2和3都不同.有没有办法找到包含.app文件的文件夹后,我可以得到相应的文件夹?我有这个麻烦.为什么…?

随机推荐

  1. 在airgapped(离线)CentOS 6系统上安装yum软件包

    我有一个CentOS6系统,出于安全考虑,它已经被空气泄漏.它可能从未连接到互联网,如果有,它很长时间没有更新.我想将所有.rpm软件包放在一个驱动器上,这样它们就可以脱机安装而无需查询互联网.但是,我在测试VM上遇到的问题是,即使指定了本地路径,yum仍然会挂起并尝试从在线存储库进行更新.另外,有没有办法使用yum-utils/yumdownloader轻松获取该包的所有依赖项和所有依赖项?目前

  2. centos – 命名在日志旋转后停止记录到rsyslog

    CentOS6.2,绑定9.7.3,rsyslog4.6.2我最近设置了一个服务器,我注意到在日志轮换后,named已停止记录到/var/log/messages.我认为这很奇怪,因为所有日志记录都是通过rsyslog进行的,并且named不会直接写入日志文件.这更奇怪,因为我在更新区域文件后命名了HUPed,但它仍然没有记录.在我停止并重新启动命名后,记录恢复.这里发生了什么?

  3. centos – 显示错误的磁盘大小

    对于其中一个磁盘,Df-h在我的服务器上显示错误的空白区域:Cpanel表明它只有34GB免费,但还有更多.几分钟前,我删除了超过80GB的日志文件.所以,我确信它完全错了.fdisk-l/dev/sda2也显示错误:如果没有格式化,我该怎么做才能解决这个问题?并且打开文件描述符就是它需要使用才能做到这一点.所以…使用“lsof”并查找已删除的文件.重新启动写入日志文件的服务,你很可能会看到空间可用.

  4. 如何在centos 6.9上安装docker-ce 17?

    我目前正在尝试在centOS6.9服务器上安装docker-ce17,但是,当运行yuminstalldocker-ce时,我收到以下错误:如果我用跳过的标志运行它我仍然得到相同的消息,有没有人知道这方面的方法?

  5. centos – 闲置工作站的异常负载平均值

    我有一个新的工作站,具有不寻常的高负载平均值.机器规格是:>至强cpu>256GB的RAM>4x512GBSSD连接到LSI2108RAID控制器我从livecd安装了CentOS6.564位,配置了分区,网络,用户/组,并安装了一些软件,如开发工具和MATLAB.在启动几分钟后,工作站负载平均值的值介于0.5到0.9之间.但它没有做任何事情.因此我无法理解为什么负载平均值如此之高.你能帮我诊断一下这个问题吗?

  6. centos – Cryptsetup luks – 检查内核是否支持aes-xts-plain64密码

    我在CentOS5上使用cryptsetupluks加密加密了一堆硬盘.一切都很好,直到我将系统升级到CentOS6.现在我再也无法安装磁盘了.使用我的关键短语装载:我收到此错误:在/var/log/messages中:有关如何装载的任何想法?找到解决方案问题是驱动器使用大约512个字符长的交互式关键短语加密.出于某种原因,CentOS6中的新内核模块在由旧版本创建时无法正确读取512个字符的加密密钥.似乎只会影响内核或cryptsetup的不同版本,因为在同一系统上创建和打开时,512字符的密钥将起作用

  7. centos – 大量ssh登录尝试

    22个我今天登录CentOS盒找到以下内容这是过去3天内的11次登录尝试.WTF?请注意,这是我从我的提供商处获得的全新IP,该盒子是全新的.我还没有发布任何关于此框的内容.为什么我会进行如此大量的登录尝试?是某种IP/端口扫描?基本上有4名匪徒,其中2名来自中国,1名来自香港,1名来自Verizon.这只发生在SSH上.HTTP上没有问题.我应该将罪魁祸首子网路由吗?你们有什么建议?

  8. centos – kswap使用100%的CPU,即使有100GB的RAM也可用

    >Linux内核是否应该足够智能,只需从内存中清除旧缓存页而不是启动kswap?

  9. centos – Azure将VM从A2 / 3调整为DS2 v2

    我正在尝试调整前一段时间创建的几个AzureVM,从基本的A3和标准A3到标准的DS2v2.我似乎没有能力调整到这个大小的VM.必须从头开始重建服务器会有点痛苦.如果它有所不同我在VM中运行CentOS,每个都有一个带有应用程序和操作系统的磁盘.任何人都可以告诉我是否可以在不删除磁盘的情况下删除VM,创建新VM然后将磁盘附加到新VM?

  10. centos – 广泛使用RAM时服务器计算速度减慢

    我在非常具体的情况下遇到服务器速度下降的问题.事实是:>1)我使用计算应用WRF>2)我使用双XeonE5-2620v3和128GBRAM(NUMA架构–可能与问题有关!

返回
顶部