#通过yum安装gcc 、gcc-c++、libevent、libevent-devel、openssl、openssl-devel、libjpeg-devel libpng-devel freetype-devel curl-devel
yum -y install gcc gcc-c++ libjpeg-devel libpng-devel cmake libevent libevent-devel yum -y install freetype-devel libxml2-devel zlib-devel glibc-devel glib2-devel bison autoconf yum -y install bzip2-devel ncurses-devel curl-devel e2fsprogs-devel krb5-devel yum -y install libidn-devel openssl-devel openld openldap-devel openldap-clients openldap-servers
#检查是否安装过rpm包 rpm -qa | grep httpd #查看进程运行情况 ps -le | grep mysql #查看所有默认系统服务 ls /etc/rc.d/init.d #停止服务 service httpd stop #卸载系统已安装的rpm包 yum remove httpd #停用SELinux vi /etc/sysconfig/selinux SELINUX=disabled setenforce 0 #停用iptables iptables -F
#解压所有tar包的shell cd /lamp ls *.tar.gz > ls.list for TAR in `cat ls.list` do tar -zxf $TAR done
#标准源代码包安装的步骤 1、.tar.gz tar -zxf //解压解包 2、./configure //配置 --prefix=/usr/local/libxml2/ 3、make //编译 4、make install > 日志文件 //安装、拷贝
#标准源代码包卸载 rm -rf 安装目录 与 源代码目录
#安装libxml2 (可忽略) #安装zlib-1.2.3 (不指定安装位置) (可忽略) #安装libpng-1.2.31 (可忽略) #安装jpeg-6b (jpegsrc.v6b) (可忽略) mkdir /usr/local/jpeg6 mkdir /usr/local/jpeg6/bin mkdir /usr/local/jpeg6/lib mkdir /usr/local/jpeg6/include mkdir -p /usr/local/jpeg6/man/man1 ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static #安装freetype-2.3.5 (可忽略) #安装autoconf-2.61(不指定安装位置) (可忽略) #安装gd-2.0.35(可忽略) ./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
yum install apr-util-devel apr apr-devel apr-util #安装apache ./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd --with-include-apr --with-pcre --enable-maintainer-mode --enable-dav --enable-modes-shared=most --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support make make install #把apache加载到系统服务中,并让其开机启动 cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
#修改httpd在文件头部加入如下内容: vi /etc/rc.d/init.d/httpd
### # Comments to support chkconfig on RedHat Linux # chkconfig: 2345 90 90 # description:http server ### chkconfig --add httpd chkconfig --del httpd chkconfig --list httpd chkconfig --levels 245 httpd off chkconfig --list httpd
#httpd.conf设置ServerName为本机name /usr/local/apache2/bin/htpasswd -c /opt/svndata/repos/conf/passwd user1 /usr/local/apache2/bin/htpasswd /opt/svndata/repos/conf/passwd user2
<Location /svn> DAV svn SVNParentPath /opt/svndata AuthType Basic AuthName "Subversion" AuthUserFile /opt/svndata/repos/conf/passwd AuthzSVNAccessFile /opt/svndata/repos/conf/authz Require valid-user </Location>
#安装libmcrypt-2.5.8 tar -zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure --prefix=/usr/local/libmcrypt/ make && make install #安装libmcrypt下的libltdl cd libltdl ./configure --enable-ltdl-install make && make install #安装ncurses-5.6 (可忽略) ./configure --with-shared --without-debug --without-ada --enable-overwrite
#安装mysql groupadd mysql grep mysql /etc/group useradd -g mysql mysql
#安装老版本mysql ./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all #安装完成后拷贝配置文件 cp support-files/my-medium.cnf /etc/my.cnf #创建数据库授权表 /usr/local/mysql/bin/mysql_install_db --user=mysql #改变mysql所属用户 chown -R mysql /usr/local/mysql chown -R mysql /usr/local/mysql/var chgrp -R mysql /usr/local/mysql /usr/local/mysql/bin/mysqld_safe --user=mysql & ps -le | grep mysqld netstat -an | grep 3306
/usr/local/mysql/bin/mysqladmin version//查看mysql版本 /usr/local/mysql/bin/mysqladmin variables //查看mysql运行参数 #为mysql设置密码 /usr/local/mysql/bin/mysql -u root SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123'); exit
#让mysql开机启动 方法1:echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local 方法2:cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld chown root.root /etc/rc.d/init.d/mysqld chmod 755 /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig --list mysqld chkconfig --levels 245 mysqld off chkconfig --list mysqld
#安装Mysql5.5版本 groupadd mysql grep mysql /etc/group useradd -g mysql mysql tar -zxvf mysql-5.5.28.tar.gz cd mysql-5.5.28 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //指定mysql安装目录 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ //指定服务器默认字符集,默认latin1 -DDEFAULT_COLLATION=utf8_general_ci \ //指定服务器默认的校对规则,默认latin1_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/data/mysql // 数据文件目录
[iyunv@ceshi6 mysql-5.5.27]# make && make install [iyunv@ceshi6 mysql-5.5.27]# chmod +w /usr/local/mysql/ [iyunv@ceshi6 mysql-5.5.27]# chown -R mysql:mysql /usr/local/mysql/ [iyunv@ceshi6 mysql-5.5.27]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so18 [iyunv@ceshi6 mysql-5.5.27]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so18 [iyunv@ceshi6 mysql-5.5.27]# mkdir -p /data/mysql/data/ [iyunv@ceshi6 mysql-5.5.27]# mkdir -p /data/mysql/log/ [iyunv@ceshi6 mysql-5.5.27]# chown -R mysql:mysql /data/mysql/ [iyunv@ceshi6 mysql-5.5.27]# cd support-files mysql配置文件 [iyunv@ceshi6 support-files]# cp my-large.cnf /etc/my.cnf cp:是否覆盖"/etc/my.cnf"? y [iyunv@ceshi6 support-files]# cp mysql.server /etc/init.d/mysqld cp:是否覆盖"/etc/init.d/mysqld"? y
初始化mysql [iyunv@ceshi6 support-files]# /usr/local/mysql/scripts/mysql_install_db \ --defaults-file=/etc/my.cnf \ --basedir=/usr/local/mysql/ \ --datadir=/data/mysql/data/ \ --user=mysql
[iyunv@ceshi6 support-files]# vi /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/data/mysql/data [iyunv@ceshi6 support-files]# chmod +x /etc/init.d/mysqld [iyunv@ceshi6 support-files]# chkconfig mysqld on service mysqld start [iyunv@ceshi6 mysql-5.5.27]# /usr/local/mysql/bin/mysql -u root -p
#允许mysql远程登录: grant all on *.* to root@'%' IDENTIFIED BY '123' with grant option; #修改root本地登录密码 update mysql.user set password=password("123") where user="root" and host="localhost"; #设置mysql字符集 vi /etc/my.cnf [client] default-character-set = utf8 [mysqld] character_set_server = utf8
#修改默认表引擎 [mysqld] 后面增加default-storage-engine=INNODB
#安装libiconv-1.14.tar.gz tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure make && make install
#增加库文件识别 vi /etc/ld.so.conf 追加/usr/local/lib ldconfig
#安装php5.2.6 cp -frp /usr/lib64/libjpeg.* /usr/lib/ cp -frp /usr/lib64/libpng* /usr/lib/ 去除openssl 与 mysqli 安装 mhash-0.9.9.9.tar
#安装php5.3.8 tar -zxvf php-5.3.8.tar.gz ./configure --prefix=/usr/local/php/ --with-iconv-dir=/usr/local --with-curl --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql --enable-sockets --with-openssl --with-mhash --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6 --with-freetype-dir=/usr/local/freetype/ --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --without-pear --with-zlib ./configure --prefix=/usr/local/php/ --with-iconv-dir=/usr/local --with-curl --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --enable-ftp --enable-sockets --with-openssl --with-mhash --with-libxml-dir=/usr --with-jpeg-dir --with-freetype-dir --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --with-zlib --without-pear --enable-fpm
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --with-iconv-dir=/usr/local --with-curl --with-config-file-path=/usr/local/php/etc/ --with-mysql=/usr/local/mysql --enable-sockets --with-openssl --with-mhash --with-libxml-dir=/usr --with-jpeg-dir --with-freetype-dir --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --with-zlib --enable-mbstring=all --enable-zip --without-pear
--with-apxs2=/usr/local/apache2/bin/apxs
-–with-iconv=/usr/local/libiconv
make ZEND_EXTRA_LIBS='-liconv'
make install
#安装成功后 cp php.ini-production /usr/local/php/etc/php.ini
#php语法错误不报错解决方案
1,php.ini里的error_reporting = E_ALL & ~E_NOTICE并且把前面的注释去掉; 2,php.ini里把display_error改为On
#安装nginx必须库文件pcre tar zxvf pcre-8.32.tar.gz cd pcre-8.32/ ./configure make && make install
#安装Nginx useradd nginx tar zxvf nginx-1.2.6.tar.gz cd nginx-1.2.6 ./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --user=nginx --group=nginx --with-http_flv_module --with-http_gzip_static_module
/configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi \ --with-pcre
make && make install
#如果运行nginx命令出错的时候 从错误看出是缺少lib文件导致,进一步查看下 ldd $(which /usr/local/nginx/sbin/nginx) 可以看出 libpcre.so.1 => not found 并没有找到,进入/lib64目录中手动链接下ln -s libpcre.so.0.0.1 libpcre.so.1
#修改Nginx配置文件让其支持php解析 #解注并修改以下项 vi /usr/local/nginx/conf/nginx.conf user nobody; worker_processes 8; error_log logs/error.log; pid /usr/local/nginx/nginx.pid; 解注21,22,23行 events { worker_connections 65535; }
location ~ \.php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; } #实现URL重写 location / { root /web/domain1; index index.html index.htm; if (!-e $request_filename) { rewrite "^/([\w]+).html$" /$1.php last; } } #配置虚拟主机 include /usr/local/nginx/conf/vhosts/www.domain1.com.conf;(在80行左右添加)
#www.domain1.com.conf文件 server { listen 80; server_name www.domain1.com; access_log logs/domain1.access.log main; location / { root /web/domain1; index index.html index.htm; if (!-e $request_filename) { rewrite "^/([\w]+).html$" /$1.php last; } } location ~ \.php$ { root /web/domain1; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /web/domain1$fastcgi_script_name; include fastcgi_params; } }
#允许查看nginx状态 location /NginxStatus { stub_status on; access_log off; allow 192.168.0.0/24; deny all; }
#检查配置文件是否有错 /usr/local/nginx/sbin/nginx -t
#配置php-fpm php5.3.8默认包含php-fpm cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf
php-fpm在/usr/local/php/sbin/下 #/usr/local/php/sbin/php-fpm ========启动php-fpm
#编辑php-fpm配置文件 vi php-fpm.conf 找到pm.min_spare_servers 去除;号,注意非注释内容pm.min_spare_servers 找到pm.max_spare_servers 去除;号,同样非注释内容pm.max_spare_servers 找到pm.start_servers 去除;号,同样非注释内容pm.start_servers ERROR: bind() for address '127.0.0.1:9000' failed: Address already in use (98) netstat -an | grep 9000查看进程,已开启 killall php-fpm 结束所有php-fpm进程 再启动php-fpm #/usr/local/php/sbin/php-fpm 成功
#修改php.ini文件后重启的步骤 pkill php-fpm /usr/local/php/sbin/php-fpm pkill -HUP nginx //平滑重启
#安装mamcache的php扩展 [iyunv@Linux ~]#tar -zxvf memcache-2.2.7.tgz 编译安装: [iyunv@Linux ~]#cd memcache-2.2.7 [iyunv@Linux ~]#/usr/local/php/bin/phpize [iyunv@Linux ~]#./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir [iyunv@Linux ~]#make && make install
#在php.ini文件中添加memcache扩展 [iyunv@Linux ~]#vi /usr/local/php/etc/php.ini 添加以下内容 extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/" extension=memcache.so
#安装memcache服务器端 tar zxvf memcached-1.4.15.tar.gz cd memcached-1.4.15 ./configure --prefix=/usr/local/memcache --with-libevent make && make install #启动memcache cd /usr/local/memcache/bin/ ./memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 128 -P /usr/local/memcache/memcached.pid #查看memcache ps -ef | grep memcached #停止memcache进程 pkill memcached
--------------------------- //附录 #添加用户级环境变量 vi ~/.bash_profile #添加系统级环境变量 vi /etc/profile PATH=$PATH:/usr/local/nginx/sbin source .bash_profile echo $PATH
#在Apache配置文件中支持php vi /etc/httpd/httpd.conf Addtype application/x-httpd-php .php .phtml /usr/lcoal/apache2/bin/apachectl restart
#利用ssh登录到局域网其他服务器 ssh -l root ip #修改iptables /etc/sysconfig/iptables #修改网卡 /etc/sysconfig/network-scripts/ifcfg-eth0 #修改DNS地址 vi /etc/resolv.conf #修改主机名与网关 vi /etc/sysconfig/network
#禁止使用ipv6: /etc/modprobe.conf – 内核模块配置文件 vi /etc/modprobe.d/disable-ipv6.conf (CentOS6版本后) /etc/sysconfig/network – 网络配置文件 1. # vim /etc/modprobe.conf 在其中加入下面这一行, install ipv6 /bin/true 保存并退出。 2. # vim /etc/sysconfig/network 在其中加入下面配置项: NETWORKING_IPV6=no IPV6INIT=no 保存并退出文件,重启网络与服务器: # service network restart # rmmod ipv6 # reboot 如果想检查当前IPv6是否已禁用,可以使用下列命令: # lsmod | grep ipv6 # ifconfig -a
#查看目录所占磁盘大小 du -sh #umount 报 device is busy 的处理方法 fuser -km /datatmp
#停掉SELinux setenforce 0 getenforce
vi /etc/selinux/config SELINUX=enfoceing 把其修改为: SELINUX=disabled
#网卡漂移 vi /etc/udev/rules.d/70-persistent-net.rules
#生成大文件 dd if=/dev/zero of=file1 bs=1M count=1000
#数据同步 rsync -ae ssh 目录名/ 192.168.10.2:/usr/local/xx
|