LAMP安装
来源:互联网 发布:万网解析设置端口 编辑:程序博客网 时间:2024/06/14 07:37
本文在CentOS 7环境下安装PHP开发环境(LAMP),各个软件版本:
Apache 2.4.25
Mysql 5.5.55
PHP 7.1.3
1. 安装依赖包
yum install wget gcc gcc-c++ make cmake bison bison-devel libaio-devel perl file patch mlocate flex diffutils readline-devel libcap-devel glibc-devel glib2-devel autoconf automake libgcrypt* libtool* openssl openssl-devel ncurses ncurses-devel libxml2 libxml2-* libmcrypt* curl curl-devel zlib zlib-devel bzip2* gd gd-devel libjpeg libjpeg-devel libpng libpng-devel mcrypt freetype* gettext gettext-devel pcre pcre-devel
可能遇到问题:无可用的软件包 mcrypt、libmcrypt*
解决方案:
yum install epel-release //扩展包更新yum update //更新yum源yum update时可能报错,进行如下修改: vi /etc/yum.repos.d/epel.repo 修改 #baseurl .... mirrorlist .... 改成 baseurl .... #mirrorlist ..... 一共两处需要修改最后安装 yum install mcypt yum install libmcrypt*
参考:http://www.cnblogs.com/linux-super-meng/p/4150987.html
2.安装Apache
2.1 下载apr、apr-util、httpd
路径如下:
apr http://apache.fayea.com//apr/apr-1.5.2.tar.gz
apr-util http://apache.fayea.com//apr/apr-util-1.5.4.tar.gz
httpd http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
2.2 安装apr
1) tar -zxvf apr-1.5.2.tar.gz -C /usr/local/src/ 2) cd /usr/local/src/apr-1.5.2/3) ./configure --prefix=/usr/local/apr4) make && make install
2.3 安装apr-util
1) tar -zxvf apr-util-1.5.4.tar.gz -C /usr/local/src/2) cd /usr/local/src/apr-util-1.5.4/3) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr4) make && make install
2.4 安装httpd
1) tar -zxvf httpd-2.4.25.tar.gz -C /usr/local/src/2) cd /usr/local/src/httpd-2.4.25/ 3) ./configure \ --prefix=/usr/local/httpd \ --sysconfdir=/etc/httpd \ --enable-rewrite \ --enable-ssl \ --enable-cgi \ --enable-expires=shared \ --enable-mods-shared \ --enable-mudules=most \ --enable-mods-shared=all \ --enable-deflate \ --enable-speling \ --enable-cache \ --enable-file-cache \ --enable-disk-cache \ --enable-mem-cache \ --enable-so \ --enable-rewrite=shared \ --enable-static-support \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --with-pcre4) make && make install
2.5 优化httpd服务
1)cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd2)修改/etc/init.d/httpd vim /etc/init.d/httpd 在第二行下添加以下两行内容 #chkconfig:345 85 15 #description:Apache httpd 3)chkconfig --add httpd //添加到系统服务4)chkconfig --level 235 httpd on //设置系统级别为235,开机自动启动
2.6 配置文件优化
vim /etc/httpd/httpd.conf 找到ServerName www.example.com:80 取消注释符号,更改为 ServerName localhost:80
2.7 启动httpd
systemctl restart httpd.service
3. 安装mysql
3.1 mysql源码路径
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.55.tar.gz
3.2 安装前准备
1)添加mysql运行账号
groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql
2)添加mysql程序相关目录
mkdir -p /usr/local/mysql mkdir -p /usr/local/mysql/data
3.3 编译安装
1)tar -zxvf mysql-5.7.18.tar.gz -C /usr/local/src/ 2)cd /usr/local/src/mysql-5.7.18/ 3)cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 \ -DSYSCONFDIR=/etc \ -DWITH_SSL=yes 4) make && make install
3.4 mysql相关目录设置主权限
chown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql/data
3.5 初始化数据库
cd /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
3.6 添加mysql数据库配置文件模板
cd /usr/local/mysql/cp suppprt-files/my-medium.conf /etc/my.cnf
3.7 添加mysql服务启动到系统服务
1)cd /usr/local/mysql/ 2)cp support-files/mysql.server /etc/init.d/mysqld 3)修改/etc/init.d/mysqld vim /etc/init.d/mysqld 修改内容: basedir=/usr/local/mysql datadir=/usr/local/mysql/data 4)chkconfig --add mysqld 5)chkconfig --level 235 mysqld on
3.8 将mysql命令加入环境变量中
修改/etc/profile文件,在文件末尾添加 PATH=/usr/local/mysql/bin:$PATH export PATHsource /etc/profile //使文件立即生效
3.9 启动mysql服务,设置管理员密码
service mysqld start 或者 systemctl start mysqld.servicemysqladmin -u root password 'root'
4. 安装PHP
4.1 下载php
http://hk1.php.net/get/php-7.1.3.tar.gz/from/this/mirror
下载之后是mirror,重命名 mv mirror php.tar.gz
4.2 编译安装
1)tar -zxvf php.tar.gz -C /usr/local/src/ 2)cd /usr/local/src/php-7.1.3/ 3)./configure \ --prefix=/usr/local/php \ --with-mysql=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-openssl \ --with-zlib \ --with-libxml-dir \ --enable-sockets \ --with-apxs2=/usr/local/httpd/bin/apxs \ --with-mcrypt \ --with-config-file-path=/etc \ --with-config-file-scan-dir=/etc/php.d \ --with-bz2 \ --with-gd \ --with-mhash \ --enable-gd-native-ttf \ --with-iconv \ --with-png-dir \ --with-jpeg-dir \ --with-gettext \ --with-curl \ --with-pear \ --with-freetype-dir \ --enable-bcmath \ --enable-xml \ --enable-mbstring \ --enable-shmop \ --enable-soap \ --enable-sysvsem \ --enable-calendar \ --enable-zip \ --enable-ftp \ --enable-maintainer-zts4) make && make install
4.3 拷贝配置文件
cp /usr/local/src/php-7.1.3/php.ini-development /etc/php.ini
4.4 修改配置文件
vi /etc/php.ini # ;default_charset = "UTF-8" //取消掉注释符号";"将值设为"utf-8";# engine = On //将此选项的开关为 on ;# short_open_tag = on //将此选项的开关为 on ,表示支持php标语;# ;date.timezone = Asia/Shanghai //取消掉注释符号";",将值设为"Asia/Shanghai"或"PRC";
5. 修改httpd.conf,支持php
vim /etc/httpd/httpd.conf 1.确定是否有加载php解释模块 LoadModule php7_module modules/libphp7.so 2.在行"AddType application/x-zip .gz .tgz"下面添加内容 AddType application/x-httpd-php .php AddType applicaton/x-httpd-php-source .php5 3.修改"DirecrotyIndex index.html",修改后"DirecrotyIndex index.html index.php" 4.重启服务 systemctl restart httpd.service
安装完成了,可以写简单PHP脚本测试了!
本文参考:http://blief.blog.51cto.com/6170059/1658994
ps:本文未安装5.7版本的mysql,因为该版本的编译对内存要求比较大,而本文是在虚拟机环境下安装的,退而求其次,选择5.5版本的mysql。
安装5.7版本时,容易卡在”Building CXX object sql/CMakeFiles/sql.dir/item_geofunc.cc.o”这里,这就是内存不足的现象,这就需要设置交换分区,大家可以参考:http://www.justwinit.cn/post/8677
。(不过,我没有试验成功)
- LAMP安装
- LAMP :安装
- lamp 安装
- 安装LAMP
- lamp 安装
- LAMP安装
- 安装LAMP
- LAMP安装
- LAMP 安装
- 安装LAMP
- lamp安装
- LAMP安装
- 安装 LAMP
- lamp 安装
- 安装lamp
- lamp安装
- lamp安装
- lamp安装
- Java集合
- MATLAB/Simulink的Arduino支持包安装教程
- 死锁发生的条件,如何避免死锁
- EditText软键盘的弹出与关闭
- Linux学习之Mysql安装
- LAMP安装
- Andriod 一个View实现Banner(加入缓存,告别oom)
- opencv 计算直方图 calcHist()
- eigenface方法
- Crack密码验证小实验
- DRP单例模式
- cocoapods的升级更新
- sqlplus基础命令
- Flexible实现H5页面的终端适配