先来看CentOS6.4+Apache-2.2.22+Mysql-5.1.63+PHP-5.2.17+phpmyadmin-3.4.10.2+ZendDebug环境安装
LAMP安装手记(CentOS6.4+Apache-2.2.22+Mysql-5.1.63+PHP-5.2.17+phpmyadmin-3.4.10.2+ZendDebug)
代码如下 | 复制代码 |
rpm -e httpd rpm -e mysql rpm -e php yum -y remove httpd php mysql-server mysql php-mysql setenforce 0 yum -y install gcc gcc-c++ make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel wget unzip wget -c http://archive.apache.org/dist/httpd/httpd-2.2.22.tar.gz wget -c http://dl.mysql.cn/mysql5/5.1/mysql-5.1.63.tar.gz wget -c http://iweb.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.10.2/phpMyAdmin-3.4.10.2-all-languages.tar.gz wget -c http://us2.php.net/get/php-5.2.17.tar.gz/from/am.php.net/mirror tar xzf httpd-2.2.22.tar.gz tar xzf mysql-5.1.63.tar.gz tar xzf php-5.2.17.tar.gz tar xzf phpMyAdmin-3.4.10.2-all-languages.tar.gz cd /tmp/httpd-2.2.22 ./configure --prefix=/usr/local/apache --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support make make install cp build/rpm/httpd.init /etc/init.d/httpd //使用init脚本管理httpd chmod 755 /etc/init.d/httpd //增加执行权限 chkconfig --add httpd //添加httpd到服务项 chkconfig httpd on //设置开机启动 ln -fs /usr/local/apache/ /etc/httpd ln -fs /usr/local/apache/bin/httpd /usr/sbin/httpd ln -fs /usr/local/apache/bin/apachectl /usr/sbin/apachectl ln -fs /usr/local/apache/logs /var/log/httpd //设置软链接以适应init脚本 groupadd mysql useradd -g mysql mysql cd /tmp/mysql-5.1.63 ./configure --prefix=/usr/local/mysql/ --localstatedir=/usr/local/mysql/data --without-debug --with-unix-socket-path=/tmp/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --with-extra-charsets=gbk,gb2312,utf8 --with-pthread make make install cp support-files/my-medium.cnf /etc/my.cnf //复制配置文件夹my.cnf /usr/local/mysql/bin/mysql_install_db --user=mysql //初始化数据库 chown -R root.mysql /usr/local/mysql chown -R mysql /usr/local/mysql/data cp /tmp/mysql-5.1.63/support-files/mysql.server /etc/rc.d/init.d/mysqld //init启动脚本 chown root.root /etc/rc.d/init.d/mysqld chmod 755 /etc/rc.d/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on ln -s /usr/local/mysql/bin/mysql /usr/bin ln -s /usr/local/mysql/bin/mysqladmin /usr/bin service mysqld start /usr/local/mysql/bin/mysqladmin -u root password '新密码' //设置root密码 安装PHP cd /tmp wget http://superb-dca2.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz wget http://superb-dca2.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz wget http://superb-sea2.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz tar xzf libmcrypt-2.5.8.tar.gz tar xzf mhash-0.9.9.9.tar.gz tar xzf mcrypt-2.6.8.tar.gz //安装libmcrypt cd /tmp/libmcrypt-2.5.8 ./configure --prefix=/usr make && make install //安装libmcrypt cd /tmp/mhash-0.9.9.9 ./configure --prefix=/usr make && make install //安装mcrypt /sbin/ldconfig //搜索出可共享的动态链接库 cd /tmp/mcrypt-2.6.8 ./configure make && make install 解决可能出现的报错: If configure fails try --with-jpeg-dir= configure: error: libpng.(a|so) not found. 解决: yum install libpng libpng-devel ln -s /usr/lib64/libjpeg.so /usr/lib/ ln -s /usr/lib64/libpng.so /usr/lib/ 解决可能出现的libiconv报错 cd /tmp wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz tar xzf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install cd /tmp/php-5.2.17 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --enable-bcmath --with-bz2 --with-curl --enable-ftp --with-gd --enable-gd-native-ttf --with-gettext --with-mhash --enable-mbstring --with-mcrypt --enable-soap --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --without-pear make make install cp php.ini-dist /usr/local/php/etc/php.ini //复制配置文件php.ini 修改apache配置文件: 在/etc/httpd/conf/httpd.conf文件中加入php文件类型解析: vi /etc/httpd/conf/httpd.conf 添加 AddType application/x-httpd-php .php .phtml .inc AddType application/x-httpd-php-source .phps 找到: ServerName www.example.com:80 修改为: ServerName localhost:80 service httpd restart //重启httpd 安装ZendOptimizer-3.3.9 64位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz 32位:http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz cd /tmp wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz tar xzf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz cd /tmp/ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ mkdir -p /usr/local/Zend/lib/ cp ZendOptimizer.so /usr/local/Zend/lib 加载zendoptimizer,建立/etc/php.d/zend.ini文件,加入如下代码加载: [zend] zend_optimizer.optimization_level=15 zend_extension=/usr/local/Zend/lib/ZendOptimizer.so service httpd restart 安装eAccelerator-0.9.6.1 cd /tmp wget http://jaist.dl.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip unzip eaccelerator-0.9.6.1.zip cd eaccelerator-0.9.6.1 export PHP_PREFIX="/usr/local/php" $PHP_PREFIX/bin/phpize ./configure -enable-eaccelerator=shared -with-php-config=$PHP_PREFIX/bin/php-config make && make install cd /tmp mkdir eaccelerator chmod 0777 eaccelerator php zenddebugger 加载失败 用php -v 查看信息 [root@E modules]# php -v Failed loading /usr/lib64/php/modules/ZendDebugger.so: libssl.so.0.9.8: cannot open shared object file: No such file or directory Failed loading /usr/local/Zend/lib/ZendOptimizer.so: /usr/local/Zend/lib/ZendOptimizer.so: undefined symbol: zend_throw_exception_internal Failed loading /usr/lib64/php/modules/ZendDebugger.so: libssl.so.0.9.8: cannot open shared object file: No such file or directory Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0 PHP 5.3.3 (cli) (built: Nov 22 2013 10:59:29) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies 原因:因为最新的linux发行版本 libssl 和 libcrypto 已升级到1.0.0 解决:只要创建相应的软链接即可 [root@E modules]# ll /usr/lib64/libssl* -rwxr-xr-x. 1 root root 221568 2?? 23 2013 /usr/lib64/libssl3.so lrwxrwxrwx. 1 root root 16 11??26 19:31 /usr/lib64/libssl.so -> libssl.so.1.0.1e lrwxrwxrwx. 1 root root 16 11??26 19:31 /usr/lib64/libssl.so.10 -> libssl.so.1.0.1e -rwxr-xr-x. 1 root root 436984 12?? 4 2013 /usr/lib64/libssl.so.1.0.1e 建立软连接: ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.0.9.8 [root@E modules]# ll /usr/lib64/libcrypto* lrwxrwxrwx. 1 root root 19 11??26 19:31 /usr/lib64/libcrypto.so -> libcrypto.so.1.0.1e lrwxrwxrwx. 1 root root 19 11??26 19:31 /usr/lib64/libcrypto.so.10 -> libcrypto.so.1.0.1e -rwxr-xr-x. 1 root root 1946880 12?? 4 2013 /usr/lib64/libcrypto.so.1.0.1e 建立软连接: ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.0.9.8 |
接着来看如何在LNAMP环境下安装JDK+Tomcat6使同一台服务器同时支持PHP和JAVA语言。
服务器系统和各软件版本如下所示:
代码如下 | 复制代码 |
[root@E ~]# uname -a |
开始安装jdk:
列出yum库可用的jdk安装包
代码如下 | 复制代码 |
[root@E ~]# yum -y list java*
|
选择jdk1.6安装
代码如下 | 复制代码 |
[root@E ~]# yum -y install java-1.6.0-openjdk* |
其它版本请自己修改对应的版本号安装
检测是否安装成功
代码如下 | 复制代码 |
[root@E ~]# java -version |
安装tomcat6
配置nginx和tomcat,使其不加端口号,直接通过域名也能访问
首先增加解析,使域名指向到主机IP,本地可以直接改host实现
解析正常
不加8080端口访问
添加8080端口访问
接下来修改nginx和tomcat的配置使其不加端口号也能访问到tomcat的webservice
代码如下 | 复制代码 |
[root@E ~]# cd /www/wdlinux/nginx/conf/vhost/ [root@E ~]# vi 111com.net.conf 添加如下内容 server { listen 80; server_name www.111com.net 111com.net; #root /www/web/master_myweb_com/public_html; index index.html index.jsp index.htm; error_page 400 /errpage/400.html; error_page 403 /errpage/403.html; error_page 404 /errpage/404.html; error_page 405 /errpage/405.html; location ~ .jsp$ { proxy_pass http://127.0.0.1:8080; include naproxy.conf; } location / { try_files $uri @tomcat; } location @tomcat { proxy_pass http://127.0.0.1:8080; include naproxy.conf; } access_log /www/web_logs/myweb_com_access.log wwwlogs; error_log /www/web_logs/myweb_com_error.log; } 重新加载nginx配置文件或重启nginx [root@E vhost]# service nginxd reload nginx: the configuration file /www/wdlinux/nginx/conf/nginx.conf syntax is ok nginx: configuration file /www/wdlinux/nginx/conf/nginx.conf test is successful |
不加端口号访问测试:
9
至此nginx已经成功将来自111com.net域名的请求代理到8080端口
如果需要配置多域名的话,还需要修改tomcat虚拟主机配置文件
默认配置文件路径:/etc/tomcat6/
默认项目路径:/var/lib/tomcat6/webapps/
tomcat默认指向/var/lib/tomcat6/webapps/ROOT目录
创建新项目目录,这里直接复制ROOT项目,进行修改
代码如下 | 复制代码 |
[root@E webapps]# pwd /var/lib/tomcat6/webapps [root@E webapps]# chown -R root 111com.net 修改权限,使新项目权限和默认项目权限一致 [root@E webapps]# chgrp -R tomcat 111com.net [root@E webapps]# ll 总用量 24 drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 examples drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 host-manager drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 manager drwxr-xr-x 3 root tomcat 4096 10月 30 22:48 111com.net drwxrwxr-x 3 root tomcat 4096 10月 30 22:06 ROOT drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 sample [root@E 111com.net]# cd 111com.net/ [root@E 111com.net]# rm -f index.html [root@E 111com.net]# vi index.jsp |
写入:WebService is Tomcat
不要忘记删除ROOT项目或者对它重命,否则新项目不生效
[root@E webapps]# mv ROOT/ ROOT.BAK
修改tomcat虚拟主机配置
[root@E 111com.net]# vi /etc/tomcat6/server.xml
在最下面
代码如下 | 复制代码 |
xmlValidation="false" xmlNamespaceAware="false"> 重启tomcat,测试http://111com.net [root@E 111com.net]# service tomcat6 restart 11 succes |