LAMP环境配置

准备工作

yum 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

mkdir -p /opt/src/
mkdir -p /opt/app/
mkdir -p /opt/case/

下载安装包

cd /opt/src/
wget -c http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz
wget -c http://mirrors.neusoft.edu.cn/mariadb/mariadb-5.5.39/source/mariadb-5.5.39.tar.gz
wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wget -c http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
wget -c http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
wget -c http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
wget -c http://kr1.php.net/distributions/php-5.6.0.tar.gz
wget -c https://github.com/nicolasff/phpredis/archive/master.zip
wget -c http://blog.zyan.cc/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget -c http://pecl.php.net/get/imagick-3.1.2.tgz
wget -c http://pecl.php.net/get/pecl_http-2.1.2.tgz
wget -c http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.33.tar.gz
wget -c http://archive.apache.org/dist/apr/apr-1.4.8.tar.gz
wget -c http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
wget -c http://apache.fayea.com/apache-mirror//httpd/httpd-2.4.10.tar.gz

编译安装包

    编译CMAKE

tar -zxvf cmake-2.8.12.tar.gz
cd cmake-2.8.12
./configure
make &&  make install
cd ../


    编译Mariadb

tar -zxvf mariadb-5.5.39.tar.gz
cd mariadb-5.5.33a
useradd -M -s /sbin/nologin mysql
mkdir -p /opt/app/mariadb/var/data
chown mysql.mysql -R /opt/app/mariadb/var/data
cmake . -DCMAKE_INSTALL_PREFIX=/opt/app/mariadb -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_DATADIR=/opt/app/mariadb/var/data -DSYSCONFDIR=/opt/app/mariadb/var -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_ARIA_STORAGE_ENGINE=1 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0
make && make install
cp support-files/my-small.cnf /opt/app/mariadb/var/my.cnf
vim /opt/app/mariadb/var/my.cnf # 编辑配置文件 省略...
/opt/app/mariadb/scripts/mysql_install_db --user=mysql --basedir=/opt/app/mariadb --datadir=/opt/app/mariadb/var/data
chown mysql.mysql -R /opt/app/mariadb/var/
/opt/app/mariadb/support-files/mysql.server start
/opt/app/mariadb/bin/mysqladmin -u root password ''
/opt/app/mariadb/bin/mysql -uroot -p #进入命令行 查看是否数据库已配置成功 退出 exit
cd ../

    

    编译Apache

useradd -M -s /sbin/nologin www
tar -zxvf pcre-8.33.tar.gz
cd pcre-8.33
./configure
make && make install

tar -zxvf httpd-2.4.10.tar.gz
tar -zxvf apr-1.4.8.tar.gz
tar -zxvf apr-util-1.5.2.tar.gz
cd httpd-2.4.10
cp -R ../apr-1.4.8 ./srclib/apr
cp -R ../apr-util-1.5.2 ./srclib/apr-util
./configure --prefix=/opt/app/apache2 --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=prefork --disable-userdir --disable-cgid --disable-cgi
make && make install
sed -i 's/^User daemon/User www/' /opt/app/apache2/conf/httpd.conf
sed -i 's/^Group daemon/Group www/' /opt/app/apache2/conf/httpd.conf
sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' /opt/app/apache2/conf/httpd.conf
sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" /opt/app/apache2/conf/httpd.conf
sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' /opt/app/apache2/conf/httpd.conf
sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' /opt/app/apache2/conf/httpd.conf
/opt/app/apache2/bin/apachectl -k start
cd ../


    编译PHP

tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
cd ../

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./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 ../

tar -zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2
./configure
make && make install
cd ../

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

tar -zxvf php-5.6.0.tar.gz
cd php-5.6.0
./configure  --prefix=/opt/app/php5 --with-apxs2=/opt/app/apache2/bin/apxs --with-config-file-path=/opt/app/php5/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-fileinfo --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif --enable-sysvsem --enable-inline-optimization --with-curl --with-kerberos --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-xsl --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-ftp --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug --enable-opcache=no
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /opt/app/php5/etc/php.ini
cd ../

tar -zxvf imagick-3.1.2.tgz
cd imagick-3.1.2
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
/opt/app/php5/bin/phpize
./configure --with-php-config=/opt/app/php5/bin/php-config
make && make install
cd ../

sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' /opt/app/php5/etc/php.ini
sed -i 's@^post_max_size.*@post_max_size = 50M@' /opt/app/php5/etc/php.ini
sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' /opt/app/php5/etc/php.ini
sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' /opt/app/php5/etc/php.ini
sed -i 's@^max_execution_time.*@max_execution_time = 300@' /opt/app/php5/etc/php.ini
sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket@' /opt/app/php5/etc/php.ini
cd ../


    编译Redis扩展

unzip master.zip
cd phpredis-master
/opt/app/php5/bin/phpize
./configure --with-php-config=/opt/app/php5/bin/php-config
make && make install
cd ../


    修改PHP配置   

vim /opt/app/php5/etc/php.ini
extension_dir = "/opt/app/php5/lib/php/extensions/no-debug-non-zts-20131226/"
#在extension_dir下面加入三行
extension=redis.so
extension=http.so
extension=imagick.so
/opt/app/apache2/bin/apachectl restart


常见错误

configure: error: *** libmcrypt was not found

export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH


configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install libxslt-devel



你可能感兴趣的:(PHP,linux,mariaDB,环境,lamp)