Centos 6.5 yum安装LAMP

平台:Centos 6.5 x86_64

1,安装源

rpm -Uvh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm


2,更新并安装基本库

yum update -y

yum install -y -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel


3,安装Apache和mysql

yum --enablerepo=remi  -y install mysql mysql-server mysql-devel httpd httpd-devel 

chkconfig httpd on

chkconfig mysqld on

service mysqld start


mysql_secure_installation

mysql -u root -p 输入密码

建立你要用的数据库。。。

4,安装php

yum --enablerepo=remi install -y php php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel

加密模块

wget http://www.dmasoftlab.com/cont/download/ioncube_loaders_lin_x86-64.tar.gz

tar zxvf ioncube_loaders_lin_x86-64.tar.gz

cp -rf  ioncube /usr/local/


sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini

sed -i 's/expose_php = On/expose_php = Off/g' /etc/php.ini 

sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /etc/php.ini

sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini

sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php.ini

sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini

sed -i 's/disable_functions =.*/disable_functions = 

passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php.ini

echo "zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so" >> /etc/php.ini


php加速模块

wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz 

tar -zxvf xcache-3.2.0.tar.gz  

cd xcache-3.2.0

phpize --clean

phpize

./configure --enable-xcache

make && make install

cat xcache.ini >> /etc/php.ini


使Apache支持php

vi /etc/httpd/conf/httpd.conf

将DirectoryIndex后添加index.php

尾部添加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php


sed -i 's/MaxKeepAliveRequests 100/MaxKeepAliveRequests 1000/g' /etc/httpd/conf/httpd.conf (修改最大同时连接数)

sed -i 's/ServerTokens OS/ServerTokens Prod/g' /etc/httpd/conf/httpd.conf (在出现错误页的时候不显示服务器操作系统的名称)

sed -i 's/ServerSignature On/ServerSignature Off/g' /etc/httpd/conf/httpd.conf  (在错误页中不显示Apache的版本)

sed -i 's/Options Indexes FollowSymLinks/Options Includes ExecCGI FollowSymLinks/g' /etc/httpd/conf/httpd.conf (允许服务器执行CGI及SSI,禁止列出目录)

sed -i 's/#AddHandler cgi-script .cgi/AddHandler cgi-script .cgi .pl/g' /etc/httpd/conf/httpd.conf (允许扩展名为.pl的CGI脚本运行)

sed -i 's/AddDefaultCharset UTF-8/AddDefaultCharset GB2312/g' /etc/httpd/conf/httpd.conf (将默认编码改为GB2312)

sed -i 's/ Options Indexes MultiViews FollowSymLinks/ Options MultiViews FollowSymLinks/g' /etc/httpd/conf/httpd.conf (不在浏览器上显示树状目录结构)

service httpd start

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html (删除默认测试页)


5,测试

vi /var/www/html/index.php

<?php

   phpinfo();

?>

在浏览器输入http://yourserverip/,看到phpinfo信息就OK了,enjoy it


你可能感兴趣的:(Centos 6.5 yum安装LAMP)