LAMP指Linux+apache+mysql/MariaDB+Perl/php/Python是一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

成都创新互联专注于屏边企业网站建设,响应式网站建设,购物商城网站建设。屏边网站建设公司,为屏边等地区提供建站服务。全流程按需搭建网站,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务
系统平台:centos 7.2
Apache版本:2.4.23
Mysql 版本:5.7.17
Php版本:7.0.12
关闭防火墙:
systemctl stop firewalld.service关闭防火墙开机自启动:
systemctl disable firewalld.service安装vim及unzip:
yum install -y vim unzip编译安装apache前需要安装apr、apr-util和pcre软件包和相关依赖包。
yum install -y gcc gcc-c++ autoconf libtoolcd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gztar zxvf apr-1.5.0.tar.gzcd apr-1.5.0./configure --prefix=/usr/local/aprmake && make installcd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gztar zxvf apr-util-1.5.3.tar.gz cd apr-util-1.5.3./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make installcd /usr/local/src/wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gz tar zxvf pcre-8.38.tar.gzcd pcre-8.38./configure --prefix=/usr/local/pcremake && make installcd /usr/local/src/wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gz tar zxvf httpd-2.4.23.tar.gzcd httpd-2.4.23./configure \--prefix=/usr/local/apache --sysconfdir=/etc/httpd \--enable-so --enable-cgi --enable-rewrite \--with-zlib --with-pcre=/usr/local/pcre \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util \--enable-mods-shared=most --enable-mpms-shared=all \--with-mpm=eventmake && make installcd /etc/httpd/vim httpd.conf1.找到Directory参数,注释掉Require all denied添加Require all granted。
2.找到ServerName参数,添加ServerName localhost:80 然后,按Esc键后输入:wq保存退出。
vim /etc/httpd/httpd.conf在配置文件最后添加以下内容:
PidFile"/var/run/httpd.pid"cd /usr/local/apache/bin/./apachectl startnetstat -tnlp #查看服务是否开启在本地浏览器中输入云服务器的公网IP地址验证,出现下图表示安装成功。
在rc.local文件中添加/usr/local/apache/bin/apachectl start,然后输入:wq保存退出。
vim /etc/rc.d/rc.localvi /root/.bash_profile在PATH=$PATH:$HOME/bin添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/apache/bin然后输入:wq保存退出,执行:
source /root/.bash_profile首先检查系统中是否存在使用rpm安装的mysql或者mariadb,如果有需要先删除后再编译安装。
rpm -qa | grep mysql #由下至上依次卸载rpm -qa | grep mariadbrpm -e xxx #一般使用此命令即可卸载成功 rpm -e --nodeps xxx #卸载不成功时使用此命令强制卸载卸载完以后用 rpm -qa|grep mariadb 或者 rpm -qa|grep mysql 查看结果。
yum install -y libaio-*#安装依赖mkdir -p /usr/local/mysqlcd /usr/local/srcwget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz tar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzmv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/groupadd mysqluseradd -g mysql -s /sbin/nologin mysql/usr/local/mysql/bin/mysqld --initialize-insecure --datadir=/usr/local/mysql/data/--user=mysqlchown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql/data/chown -R mysql:mysql /usr/local/mysqlcd /usr/local/mysql/support-files/cp mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld # 添加执行权限vim /etc/rc.d/rc.local添加/etc/init.d/mysqld start到rc.local文件中,然后输入:wq保存退出。
vi /root/.bash_profile在PATH=$PATH:$HOME/bin添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib然后输入:wq保存退出,输入:
source /root/.bash_profile/etc/init.d/mysqld start初始化后mysql为空密码可直接登录,为了保证安全性需要修改mysql的root用户密码。
mysqladmin -u root password 'xxxx'mysql -uroot -p密码#-p和密码之间无空格依赖安装:
yum install php-mcrypt libmcrypt libmcrypt-devel libxml2-devel openssl-devel libcurl-devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 libjpeg-turbo-devel libmcrypt-devel mysql-devel -ywget http://zy-res.oss-cn-hangzhou.aliyuncs.com/php/php-7.0.12.tar.gztar zxvf php-7.0.12.tar.gzcd php-7.0.12./configure \--prefix=/usr/local/php \--with-mysql=mysqlnd --with-openssl \--with-mysqli=mysqlnd \--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 \--enable-maintainer-zts \--disable-fileinfomake && make installcd php-7.0.12cp php.ini-production /etc/php.inivim /etc/httpd/httpd.conf在配置文件最后添加如下二行:
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps定位到 DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html/usr/local/apache/bin/apachectl restartcd /usr/local/apache/htdocs/vim index.php #添加如下内容phpinfo();?>访问云服务器的公网IP/index.php,出现如下页面表示解析成功。
mkdir -p /usr/local/apache/htdocs/phpmyadmincd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/phpMyAdmin-4.1.8-all-languages.zipunzip phpMyAdmin-4.1.8-all-languages.zipmv phpMyAdmin-4.1.8-all-languages/* /usr/local/apache/htdocs/phpmyadmin下面关于LAMP相关的内容你可能也喜欢: