编译安装lamp
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译安装lamp相关的知识,希望对你有一定的参考价值。
yum install gcc gcc-c++ ncurses-devel perl
安装cmake
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -xzvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
make
make install
添加组合用户
groupadd mysql
useradd -r -g mysql mysql
创建文件夹
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/data
安装mysql
tar -zxv -f mysql-5.6.16.tar.gz
cd mysql-5.6.16
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
初始化数据库
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
修改root密码
mysqladmin -u root password ‘root‘
设置mysql开机启动
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
启动MySQL
service mysqld start
设置mysql客户端环境变量
cd ~
vi .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
登陆mysql
mysql -uroot -proot
mysql客户端中添加远程访问用户及授权
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION
刷新权限
FLUSH PRIVILEGES
mysql密码修改方法
方法1: 用SET PASSWORD命令
首先登录MySQL。
格式:mysql> set password for 用户名@localhost = password(‘新密码‘);
例子:mysql> set password for [email protected] = password(‘123‘);
方法2:用mysqladmin
格式:mysqladmin -u用户名 -p旧密码 password 新密码
例子:mysqladmin -uroot -p123456 password 123
方法3:用UPDATE直接编辑user表
首先登录MySQL。
mysql> use mysql;
mysql> update user set password=password(‘123‘) where user=‘root‘ and host=‘localhost‘;
mysql> flush privileges;
编译安装 httpd-2.4.6
包下载地址:http://pan.baidu.com/s/1miHrZdQ 密码:p6ny
由于httpd依赖于apr-1.4,apr-util-1.4,所以得安装1.4及以上版本。
首先安装apr和apr-util
tar xf apr-1.5.0.tar.bz2
./configure --prefix=/usr/local/apr
make && make install
tar xf apr-util-1.5.2.tar.bz2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
安装httpd2.4
yum -y install pcre-devel
yum -y install openssl-devel
groupadd -r apache
useradd -r -g apache apache
tar xf httpd-2.4.6.tar.bz2
./configure --prefix=/usr/local/apache --sysconf=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
把httpd加入到开机启动服务
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
编辑/etc/rc.d/init.d/httpd在文件第二行加入
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig --level 2345 httpd on
service httpd restart
编译安装php
tar xf php-5.4.26.tar.bz2
cd php-5.4.26
yum install -y epel-release
yum install libxml2-devel libjpeg-* libpng-devel freetype-devel gd-devel libmcrypt-devel openssl-devel
tar xf
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6 --disable-fileinfo
配置php.ini
进入tar包解压后的文件夹
cp php.ini-production /etc/php.ini
vim /etc/httpd/httpd.conf
修改DirectoryIndex 加入index.php
DirectoryIndex index.html index.php
添加两行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
server httpd restart
测试PHP的连接
cd /usr/local/apache/htdocs/
mv index.html index.php
vi index.php 加入如下内容
<?php
phpinfo();
?>
以上是关于编译安装lamp的主要内容,如果未能解决你的问题,请参考以下文章