本文共 4281 字,大约阅读时间需要 14 分钟。
LAMP安装步骤(操作系统CentOS6,apache 2.4.37,mariadb5.5.62,php5.5.6)
一、准备阶段1.系统初始环境设置sed -i 's#HOSTNAME=CentOS6_Template#HOSTNAME=CentOS6_LAMP#g' /etc/sysconfig/networkhostname CentOS6_LAMPsed -i "s#192.168.1.1#61.147.37.1#g" /etc/sysconfig/network-scripts/ifcfg-eth0sed -i "s#10.0.0.254#10.0.0.168#g" /etc/sysconfig/network-scripts/ifcfg-eth0sed -i "s#172.16.1.254#172.16.1.168#g" /etc/sysconfig/network-scripts/ifcfg-eth12.安装相关组件依赖包
yum groupinstall "Development tools" "Server Platform Development" -yyum install autoconf patch m4 bison bzip2-devel pam-devel gmp-devel libicu-devel curl-devel pcre-devel libtool-libs libtool-ltdl-devel libwebp-devel libXpm-devel libvpx-devel libjpeg-devel libpng-devel freetype-devel oniguruma-devel aspell-devel enchant-devel readline-devel unixODBC-devel libtidy-devel openldap-devel libxslt-devel net-snmp net-snmp-devel zlib-devel openssl-devel libxml2-devel lynx expat-devel lua-devel lua jansson-devel pcre-devel ncurses-devel cmake m4 bison libaio libaio-devel numactl-devel yum-utils gcc gcc-c++ make wget perl curl bzip2 readline readline-devel net-tools python-devel ca-certificates epel-release ntpdate crontabs vim lrzsz php-mcrypt libmcrypt libmcrypt-devel libxml2 libxml2-devel -y二、编译安装apache2.4.37
1.下载apache程序包以及相关依赖包wget wget wget 2.分别解压apr以及apr-util包,并编译安装至/usr/localtar zxf apr-1.5.0.tar.gzcd apr-1.5.0/./configure --prefix=/usr/local/aprmake -j8 && make installcd ..tar zxf apr-util-1.5.1.tar.gz cd apr-util-1.5.1/./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake -j8 && make install3.解压并编译安装httpd包,注意相关编译选项tar zxf httpd-2.4.37.tar.gz cd httpd-2.4.37/./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=eventmake -j8 && make install4.安装后设置环境变量以及设置并启动服务
echo "export PATH=/usr/local/mysql/bin:/usr/local/apache/bin:$PATH" >/etc/profile.d/lamp.sh. /etc/profile.d/lamp.shcp httpd /etc/rc.d/init.d/httpdsed -ir '/CONFFILE/d;73a\tCONFFILE=/etc/httpd24/httpd.conf' /etc/rc.d/init.d/httpdsed -i "203aServerName localhost:80" /etc/httpd24/httpd.confchkconfig --add httpdservice start httpdss -tnl|grep :80三、下载mariadb并编译安装
1.下载并解压mariadb程序包(这里以版本5.5.62为例)wget tar zxf mariadb-5.5.62-linux-x86_64.tar.gz -C /usr/local/2.添加mysql用户与用户组groupadd -r -g 306 mysqluseradd -r -g 306 -u 306 mysqlid mysql 3.设置mysql文件夹权限以及生成初始数据库文件cd /usr/local/ln -s /usr/local/mariadb-5.5.62-linux-x86_64/ mysqlcd mysqlchown -R root.mysql ./*mkdir /mydatacd /mydata/mkdir data/chown mysql.mysql /mydata/datascripts/mysql_install_db --user=mysql --datadir=/mydata/datachown mysql.mysql /mydata/data4.生成mysql主配置文件以及生成服务脚本并启动服务mkdir /etc/mysql -pcp support-files/my-large.cnf /etc/mysql/my.cnfsed -i '41a datadir = /mydata/data\ninnodb_file_per_table = on\nskip_name_resolve = on' /etc/mysql/my.cnftouch /var/log/mysqld.logchown mysql.mysql /var/log/mysqld.logcp support-files/mysql.server /etc/rc.d/init.d/mysqldchkconfig --add mysqldchkconfig --list mysqldservice mysqld start ss -tnl|grep :3306四、编译安装php
1.下载并解压php程序包(这里以版本5.5.6为例)wget tar zxf php-5.5.6.tar.gz2.编译安装php程序,注意相关编译选项
cd php-5.5.6/./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-ztsmake -j8 && make install3.配置apache相应配置文件,并重启apache服务
sed -i 's#DirectoryIndex index.html#DirectoryIndex index.php index.html#g' /etc/httpd24/httpd.confsed -i '401aAddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps' /etc/httpd24/httpd.confservice httpd restarthttpd -M|grep php54.lamp安装完成后测试客户端访问
cd /usr/local/apache/htdocs/mv index.html index.phpvim index.php<?php$conn=mysql_connect('127.0.0.1','root','');if($conn)echo "ok";elseecho "failure";mysql_close();phpinfo();?>)转载于:https://blog.51cto.com/9447803/2336973