sowhy

慕道者

博客园 首页 新随笔 联系 订阅 管理
---------------------------------------更换163软件源,此步可以省略,记得把repo文件里面的6.5改成当前版本号
yum makecache && yum -y update
---------------------------------------配置防火墙,开启80端口、3306端口
备注:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,
正确的应该是添加到默认的22端口这条规则的下面
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
---------------------------------------关闭SELINUX
vi /etc/selinux/config
-----------------------------------
#SELINUX=enforcing       #注释掉
#SELINUXTYPE=targeted    #注释掉
SELINUX=disabled     #增加这一行
------------------------------#重启系统
reboot
---------------------------------------依赖组件
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre-devel  zlib-devel gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* unzip vim
---------------------------------------安装pcre,默认gz文件包位置:/usr/local/src
cd /usr/local/src
=========================上传文件
mkdir /usr/local/pcre && tar zxvf pcre-8.35.tar.gz && cd pcre-8.35 && ./configure --prefix=/usr/local/pcre && make && make install && cd ../
---------------------------------------安装mysql
groupadd mysql && useradd -g mysql mysql -s /bin/false && mkdir -p /home/mysqldata && chown -R mysql:mysql /home/mysqldata && mkdir -p /usr/local/mysql && cd /usr/local/src && tar zxvf mysql-5.1.56.tar.gz && cd mysql-5.1.56
./configure --prefix=/usr/local/mysql --localstatedir=/home/mysqldata --enable-assembler --enable-static --with-mysqld-user=mysql --with-big-tables --enable-thread-safe-client --enable-local-infile --with-charset-utf8 --with-extra-charsets=all && make && make install
cp ./support-files/my-huge.cnf /etc/my.cnf
vim /etc/my.cnf
=============在[mysqld]中增加下面一行
datadir = /home/mysqldata
=============
./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld

chkconfig mysqld on
vim /etc/rc.d/init.d/mysqld
============================下面两个参数,等号后面是空,把后面的添加进去
basedir = /usr/local/mysql
datadir = /home/mysqldata
============================
service mysqld start
vim /etc/profile
=====================================================在export之后增加下面这一行
export PATH=$PATH:/usr/local/mysql/bin
=====================================================
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
---------------------------------------安装 nginx
cd /usr/local/src
groupadd www && useradd -g www www -s /bin/false && mkdir -p /usr/local/nginx && tar zxvf nginx-1.7.3.tar.gz && cd nginx-1.7.3 && ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.35
make && make install
vim /etc/rc.d/init.d/nginx
=======================================================这个文件是新建的,完整输入下面的内容
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
.  /etc/rc.d/init.d/functions
# Source networking configuration.
.  /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid
}
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;

status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac
exit $RETVAL
=======================================================
:x!保存退出
chmod 775 /etc/rc.d/init.d/nginx
chkconfig nginx on
service nginx restart
===========================上面这一步执行完之后,就可以在浏览器里面输入虚拟机的ip地址访问了
---------------------------------------php组件支持软件安装
cd /usr/local/src && tar -zxvf libiconv-1.13.1.tar.gz && cd libiconv-1.13.1/ && ./configure --prefix=/usr/local && make && make install && cd ../

tar -zxvf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7/ && ./configure &&  make && make install && /sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install && make && make install && cd ../../

tar -zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9/ && ./configure && make && make install && cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

tar -zxvf mcrypt-2.6.8.tar.gz &&cd mcrypt-2.6.8/ && /sbin/ldconfig && ./configure && make && make install && cd ../

cd /usr/local/src && tar -zvxf php-5.3.10.tar.gz && cd  php-5.3.10 && mkdir -p /usr/local/php
---------------------------------------x64库文件支持,x64才需要执行下面这一行
cp -frp /usr/lib64/libldap* /usr/lib/
---------------------------------------nginx
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local/ --with-freetype-dir --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-jpeg-dir --with-png-dir --with-zlib --with-mhash --enable-sockets --enable-ftp --with-libxml-dir --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --enable-fpm --with-xmlrpc --enable-zip --enable-soap --without-pear
---------------------------------------
make ZEND_EXTRA_LIBS='-liconv'
make install

cp php.ini-production /usr/local/php/etc/php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
======================================下面的前面五行是增加,后面两行是前面参数在,后面的加上www,最后一排好像是把前面的分号去掉就可以了
[global]
pid = run/php-fpm.pid

[www]
pm.max_children = 64
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024

user = www
group = www
=============================

cp /usr/local/src/php-5.3.10/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
vim /usr/local/php/etc/php.ini
=============================================php.ini文件用默认的也可以,这里面的有引起配置有问题
找到:;open_basedir =
修改为:open_basedir = .:/tmp/   #防止php木马跨站,重要!!========这一句好像有问题
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC   #设置时区
找到:expose_php = On
修改为:expose_php = OFF  #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF  #关闭错误提示
==============================================================================
---------------------------------------配置nginx支持php
vim /usr/local/nginx/conf/nginx.conf
===========================================这里面的配置注意找一下,有的是增加后面的值,有的是去掉分号就可以了
user www www;
=========================================http{}这一个节点的大括号里面添加这个
autoindex on; #开启nginx目录浏览功能
autoindex_exact_size off; #文件大小从KB开始显示
autoindex_localtime on; #显示文件修改时间为服务器本地时间

其中server段增加如下配置:
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
    include        fastcgi_params;
  }
 其中  location /{} 中 index index.html index.htm 改为
 index  index.php  index.html index.htm;
===========================================
到这一步就算完成了,下面的是配置zend加密以及多域名绑定的
==================pdo-mysql支持20140716
cd /usr/local/src && tar zxvf pdo_mysql-1.0.2.tgz && cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make && make install
vim /usr/local/php/etc/php.ini
==========================找到extension=php-mysql.dll后面添加一行
extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so"
---------------------------------------配置php支持Zend Guard
安装Zend Guard
cd /usr/local/src && mkdir /usr/local/zend
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ ##64位
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ ##32位
vim + /usr/local/php/etc/php.ini##最后一行的下面添加
====================================================
[Zend Guard]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
============================================
---------------------------------------
mkdir -p /home/www/vhosts/ && mkdir -p /home/www/html/ && chown -R www:www /home/www/vhosts/ && chown www.www /home/www/html/ -R && chmod 700 /home/www/html/ -R
---------------------------------------测试及相关组件参数
cd /usr/local/nginx/html/   #进入nginx默认网站根目录
vim index.php  #新建index.php文件
==================== 
<?php
phpinfo();
?>
======================完成后重启才能有效=====================
http://192.168.9.8/index.php
#############################################################################
---------------------------------------多域名支持
vim /usr/local/nginx/conf/nginx.conf
==========================================
include /home/www/vhosts/*.conf;
==========================================
CREATE USER chy@localhost IDENTIFIED BY '123456';  
grant all on qyoa.* to chy@localhost;
grant alter,create,delete,drop,index,insert,select,update on qyoa.* to chy@localhost;
==========================================

1.2.2 设置mysql密码 
mysql>; USE mysql; 
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root'; 
mysql>; FLUSH PRIVILEGES; 
1.2.3 允许远程登录 
mysql -u root -p 
Enter Password: <your new password> 
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; 
完成后就能用mysql-front远程管理mysql了。 


============================第二种yum安装方法============================
CentOS下yum安装LAMP
 
1. 用yum安装Apache,Mysql,PHP. 
1.1安装Apache 
yum install httpd httpd-devel 
安装完成后,用/etc/init.d/httpd start 启动apache 
设为开机启动:chkconfig httpd on 
1.2 安装mysql 
1.2.1 yum install mysql mysql-server mysql-devel 
同样,完成后,用/etc/init.d/mysqld start 启动mysql 
1.2.2 设置mysql密码 
mysql>; USE mysql; 
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root'; 
mysql>; FLUSH PRIVILEGES; 
1.2.3 允许远程登录 
mysql -u root -p 
Enter Password: <your new password> 
mysql>GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION; 
完成后就能用mysql-front远程管理mysql了。 
1.2.4 设为开机启动 
chkconfig mysqld on 
2. 安装php 
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml 
/etc/init.d/httpd start 
3. 测试一下 
3.1在/var/www/html/新建个test.php文件,将以下内容写入,然后保存。 
<? 
phpinfo(); 
?> 
3.2 防火墙配置 
a.添加.允许访问端口{21: ftp, 80: http}. 
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT 
iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT 
b.关闭防火墙{不推荐}. 
service iptables stop 
c.重置加载防火墙 
service iptables restart 
3.3然后在客户端浏览器里打开http://serverip/test.php,若能成功显示,则表示安装成功。 
至此,安装完毕。感慨,yum真是太好用了。
CentOS 打开防火墙80端口
 
注意:有时安装好可能无法访问,需要打开80端口
很大的原因是防火墙:
通过/etc/init.d/iptables status命令查询是否有打开80端口,如果没有可通过两种方式处理:
1.修改vi /etc/sysconfig/iptables命令添加使防火墙开放80端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
2.关闭防火墙
/etc/init.d/iptables stop 
#start 开启 
#restart 重启
永久性关闭防火墙chkconfig --level 35 iptables off

  环境包下载地址: http://pan.baidu.com/s/1i3XTcoP

posted on 2016-03-17 13:11  sowhy  阅读(314)  评论(0编辑  收藏  举报