LAMP安装
一、基于yum一键安装LAMP
yum install httpd httpd-devel mariadb mariadb-server mariadb-devel php php-devel php-mysql -y
systemctl start httpd
systemctl start mariadb
二、基于源码安装LAMP
1、Apache WEB安装
yum install apr apr-devel apr-util apr-util-devel gcc-c++ wget tar -y cd /usr/src wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.35.tar.gz tar -zxf httpd-2.4.35.tar.gz cd httpd-2.4.35 ./configure --prefix=/usr/local/apache/ --enable-rewrite --enable-so make && make install /usr/local/apache/bin/apachectl start
2、MYSQL数据库安装,基于MYSQL5.5编译安装:
yum install -y cmake ncurses-devel ncurses cd /usr/src wget -c https://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.20.tar.gz tar -xzf mysql-5.5.20.tar.gz cd mysql-5.5.20 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DMYSQL_DATADIR=/data/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DWITH_XTRADB_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 \ -DWITH_EXTRA_CHARSETS=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_BIG_TABLES=1 \ -DWITH_DEBUG=0 make make install cd /usr/local/mysql/ \cp support-files/my-large.cnf /etc/my.cnf \cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig --level 35 mysqld on mkdir -p /data/mysql useradd mysql /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql/ ln -s /usr/local/mysql55/bin/* /usr/bin/ /etc/init.d/mysql restart
3、PHP服务安装
yum install -y libxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel cd /usr/src wget -c http://cn2.php.net/distributions/php-5.6.38.tar.gz tar -zxf php-5.6.38.tar.gz cd php-5.6.38 ./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-bz2 \
--with-curl \
--enable-ftp \
--enable-sockets \
--disable-ipv6 \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--with-iconv-dir \
--enable-mbstring \
--enable-calendar \
--with-gettext \
--with-ldap \
--with-libxml-dir \
--with-zlib \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd \
--enable-dom \
--enable-xml \
--enable-fpm \
--with-libdir=lib64 \
--enable-bcmath make && make install
4、PHP需与Apache整合:
为了能让Apache发布PHP页面,需要将PHP安装完成后的libphp5.so模块与Apache进行整合,vim httpd.conf编辑配置文件,加入如下代码:
加入如下代码:
AddType application/x-httpd-php .php
修改DirectoryIndex为如下:
DirectoryIndex index.php index.html index.htm
5、测试Apache+PHP环境:
创建PHP测试页面,在/usr/local/apache/htdocs目录下创建index.php测试页面,执行如下命令自动创建
cat >/usr/local/apache/htdocs/index.php<<EOF <?php phpinfo(); ?> EOF
/usr/local/apache/bin/apachectl restart
6、Discuz PHP论坛安装
wget http://download.comsenz.com/DiscuzX/3.1/Discuz_X3.1_SC_UTF8.zip wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip
unzip Discuz_X3.3_SC_UTF8.zip -d /usr/local/apache/htdocs
cd /usr/local/apache/htdocs/
\mv upload/* .
chmod 757 -R data/ uc_server/ config/ uc_client/
7、wordpress博客安装
wget https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz tar -zxf wordpress-4.7.4-zh_CN.tar.gz
mv wordpress/* /usr/local/apache/htdocs