为了账号安全,请及时绑定邮箱和手机立即绑定

apache+mysql+php整理

标签:
PHP

以前整理的,在5.8环境下编译基本没出问题

yum install gcc gcc-c++ make automake autoconf kernel-devel -y


tar -xzvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure --prefix=/usr/local/zlib2

make

make install


tar -xzvf httpd-2.2.3.tar.gz

cd httpd-2.2.3

./configure \

--prefix=/usr/local/apache \

--enable-module=so \

--enable-mods-shared=all \

--enable-rewrite=shared \

--enable-static-support \

--enable-authn-dbm=shared \

--enable-threads \

--with-mpm=worker \

--with-z=/usr/local/zlib2 \

--disable-cgid \

--disable-cgi \

--disable-userdir \


make

make install


vi /usr/local/apache/conf/extra/httpd-mpm.conf


<IfModule mpm_worker_module>

StartServers         10

ServerLimit         100

MaxClients         3000

MinSpareThreads     150

MaxSpareThreads     300

ThreadLimit         64

ThreadsPerChild     30

MaxRequestsPerChild 10000

</IfModule>


vi /usr/local/apache/conf/extra/httpd-vhosts.conf


<VirtualHost *:80>

ServerAdmin adyw@aodiansoft.com

DocumentRoot /usr/local/apache/htdocs/

ServerName test.example.com

ServerAlias teset.example.com

ErrorLog logs/test-error_log

CustomLog logs/test-access.log combined

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %h %T" combined

<Directory "/usr/local/apache/htdocs">

Options FollowSymLinks Includes

AllowOverride All

Order deny,allow

Allow from all

</Directory>

</VirtualHost>


vi /usr/local/apache/conf/httpd.conf




注释掉以下部分:

<Directory />

Options FollowSymLinks

AllowOverride None

Order deny,allow

Deny from all

</Directory>


修改DirectoryIndex为:

DirectoryIndex index.html index.shtml index.php default.php


取消注释:

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml


添加应用类型:

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps


取消注释:

Include conf/extra/httpd-mpm.conf

Include conf/extra/DB_INFO.conf

Include conf/extra/httpd-vhosts.conf


添加监控

ExtendedStatus On

<Location /server-status>

SetHandler server-status

Order Deny,Allow

Deny from all

Allow from 117.79.239.98

Allow from 117.79.239.197

</Location>


/usr/local/apache/bin/apachectl -t

/usr/local/apache/bin/apachectl start

/usr/local/apache/bin/apachectl stop

/usr/local/apache/bin/apachectl restart


添加自启动:

echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local


yum -y install ncurses-devel libtool



tar xzvf mysql-5.1.57.tar.gz

cd mysql-5.1.57

./configure \

--prefix=/usr/local/mysql \

--enable-assembler \

--enable-profiling \

--enable-local-infile \

--enable-thread-safe-client \

--with-client-ldflags=-all-static \

--with-mysqld-ldflags=-all-static \

--with-extra-charsets=complex \

--with-big-tables \

--with-readline \

--with-ssl \

--with-embedded-server \

--with-plugins=innobase,myisam,myisammrg,partition \

--without-debug \


make && make install


useradd mysql


cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf


初始化数据库

/usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/var


给root账号添加密码:

/usr/local/mysql/bin/mysqladmin -u root password 123456

修改管理员root密码:

/usr/local/mysql/bin/mysqladmin  -u root -p123456 password 123456


进入数据库管理界面,删除空密码账号:

mysql>

delete from user where password='';


修改配置文件:

拷贝配置文件到/etc下面重启服务


修改目录权限

cd /usr/local/mysql

chown -R root.mysql *

chown -R mysql var


/usr/local/mysql/share/mysql/mysql.server start

/usr/local/mysql/share/mysql/mysql.server stop

/usr/local/mysql/share/mysql/mysql.server restart


echo "/usr/local/mysql/share/mysql/mysql.server start" >> /etc/rc.local




tar -zxvf jpegsrc.v6b.tar.gz

cd jpeg-6b

./configure --prefix=/usr/local/jpeg6


mkdir /usr/local/jpeg6

mkdir /usr/local/jpeg6/include

mkdir /usr/local/jpeg6/lib

mkdir /usr/local/jpeg6/bin

mkdir /usr/local/jpeg6/man

mkdir /usr/local/jpeg6/man/man1

make

make install-lib

make install



yum install zlib-devel -y

tar -zxvf libpng-1.2.34.tar.gz

cd libpng-1.2.34

./configure --prefix=/usr/local/libpng2

make

make install



tar -zxvf freetype-2.2.1.tar.gz

cd freetype-2.2.1

./configure --prefix=/usr/local/freetype2

make

make install


tar -zxvf gd-2.0.33.tar.tar

cd gd-2.0.33

./configure \

--prefix=/usr/local/gd2 \

--with-zlib=/usr/local/zlib2/ \

--with-png=/usr/local/libpng2/ \

--with-jpeg=/usr/local/jpeg6/ \

--with-freetype=/usr/local/freetype2/ \

vi  gd_png.c

找到png.h改成/usr/local/libpng2/include/png.h

make && make install

{有报错 yum install perl}



安装curl-7.17.1


tar zxvf curl-7.17.1.tar.gz

cd curl-7.17.1

./configure --prefix=/usr/local/curl

make

make install




yum -y install openssl-devel libxml2-devel



tar zxvf php-5.2.9.tar.gz

cd php-5.2.9

./configure --prefix=/usr/local/php5 \

--with-apxs2=/usr/local/apache/bin/apxs \

--with-config-file-path=/usr/local/php5/etc \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \

--with-gd=/usr/local/gd2 \

--with-jpeg-dir=/usr/local/jpeg6 \

--with-png-dir=/usr/local/libpng2 \

--with-freetype-dir=/usr/local/freetype2 \

--with-zlib-dir=/usr/local/zlib2 \

--with-openssl \

--with-curl=/usr/local/curl \

--enable-zip \

--enable-soap \

--enable-sockets \

--enable-mbstring \

--enable-pdo \



cd php-5.2.9

./configure --prefix=/usr/local/php5 \

--with-config-file-path=/usr/local/php/etc \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \

--with-jpeg-dir=/usr/local/jpeg6 \

--with-png-dir=/usr/local/libpng2 \

--with-freetype-dir=/usr/local/freetype2 \

--with-zlib-dir=/usr/local/zlib2 \

--with-openssl \

--with-curl=/usr/local/curl \

--enable-zip \

--enable-soap \

--enable-sockets \

--enable-mbstring \

--enable-pdo \


make && make install


mkdir -p /usr/local/php/lib/php/extensions/



将php.ini放到/usr/local/php/etc/下面




重启apache,然后查看:

phpinfo网页测试是否正常,是否支持

xx.php

<?php

phpinfo();

?>

openssl/sockets/pdo_mysql/pdo/mysql/mysqli/jpeg/png/zip等



tar zxvf libevent-1.3.tar.gz

cd libevent-1.3

./configure --prefix=/usr

make

make install



安装memcached服务


tar zxvf memcached-1.4.0.tar.gz

cd memcached-1.4.0

./configure --with-libevent=/usr

make

make install


启动:/usr/local/bin/memcached -d -m 256 -u root


检查tcp 11211端口是否打开

加入自启动:

echo "/usr/local/bin/memcached -d -m 256 -u root" >> /etc/rc.local



tar zxvf memcache-2.2.5.tgz

cd memcache-2.2.5

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

cd /usr/local/php/lib/php/extensions/

cd no-debug-zts-20060613/

mv memcache.so ../



tar zxvf mongodb-linux-i686-1.8.0.tgz

mv mongodb-linux-i686-1.8.0 /usr/local/mongodb


**** 核心一般共用 ****

创建数据存储目录

mkdir -p /data/mongodb


启动mongodb服务端

setsid /usr/local/mongodb/bin/mongod --dbpath /data/mongodb/ --logpath /usr/local/mongodb/mongodb.log --logappend --maxConns 500 --auth --port 27017


echo "setsid /usr/local/mongodb/bin/mongod --dbpath /data/mongodb/ --logpath /usr/local/mongodb/mongodb.log --logappend --maxConns 500 --auth --port 27017" >> /etc/rc.local

****************


安装mongo php扩展:

/usr/local/php/bin/pecl install mongo

{若提示不行,重启mongo和apache,然后移动.so}

出现下面的提示说明安装成功:


Build process completed successfully

Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/mongo.so'

install ok: channel://pecl.php.net/mongo-1.1.4

configuration option "php_ini" is not set to php.ini location

You should add "extension=mongo.so" to php.ini



tar jxvf eaccelerator-0.9.6.1.tar.bz2

cd eaccelerator-0.9.6.1/

/usr/local/php/bin/phpize

./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config

make

make install

cd ../



mkdir -p /usr/local/php/lib/php/eaccelerator_cache

chmod -R 777 /usr/local/php/lib/php/eaccelerator_cache/


移动.so 至扩展目录下

vi /usr/local/lib/php.ini


按shift+g键跳到配置文件的最末尾,加上以下配置信息:




[eaccelerator]

zend_extension="/usr/local/lib/php/extensions/eaccelerator.so"

eaccelerator.shm_size="32"  

eaccelerator.cache_dir="/usr/local/lib/php/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="3600"

eaccelerator.shm_prune_period="3600"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

eaccelerator.keys = "disk_only"  

eaccelerator.sessions = "disk_only"

eaccelerator.content = "disk_only"


查看phpinfo是否安装成功



点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消