CentOS 6.5 透過 yum 快速部署 LAMP (Linux + Apache + MySQL + PHP) 生產環境,含 EPEL/REMI 源、PHP 加速與安全設定。

rpm -Uvh https://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh https://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y update
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel
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 # 設定 root 密碼、移除匿名帳號等
mysql -u root -p
CREATE DATABASE yourdb;
yum --enablerepo=remi -y install 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
/usr/local/ioncube → 修改 php.ini 加入 zend_extension=/usr/local/ioncube/ioncube_loader_lin_5.4.so。phpize && ./configure --enable-xcache && make && make install → 將 xcache.ini 內容附加至 php.ini。post_max_size = 50Mupload_max_filesize = 50Mdate.timezone = PRCcgi.fix_pathinfo = 0max_execution_time = 300disable_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_servervi /etc/httpd/conf/httpd.conf
# DirectoryIndex 後加入 index.php
DirectoryIndex index.html index.php
service httpd start
echo "" > /var/www/html/index.php
# 瀏覽器訪問 https://your_server_ip/ 應顯示 PHP 資訊頁
完成上述步驟,LAMP 環境即部署就緒,可部署 WordPress、Drupal 等 PHP 應用。