您的位置:首页 > 其它

搭建lamp环境

2016-05-07 21:23 316 查看
1:首先要安装的mysql:一般我们把下载的安装包放在/usr/local/src下面:
首先解压安装包:
[root@master src]# tar zvxf mysql-5.1.73-linux-i686-glibc23.tar.gz
把解压后的文件移至/usr/local/下:
[root@master src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
建立mysql用户,但是用户不能在终端登录(不创建家目录):
[root@master src]# useradd -s /sbin/nologin -M mysql
创建数据库文件并且,修改数据库文件权限为mysql!
[root@master src]# cd /usr/local/mysql/
[root@master mysql]# mkdir -p /data/mysql
[root@master mysql]# chown -R mysql:mysql /data/mysql
初始化数据库:
[root@master mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
WARNING: The host 'master' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h master password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

/出现两个ok说明,初始化完成!
拷贝配置文件,如果配置文件已经存在,直接覆盖即可:
[root@master mysql]# cp support-files/my-large.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
拷贝启动脚本,并且修改启动脚步文件权限为755
[root@master mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@master mysql]# chmod 755 !$
chmod 755 /etc/init.d/mysqld
修改启动脚步,把启动脚本中的“datadir=”修改为“datedir = /data/mysql”

[root@master mysql]# vim /etc/init.d/mysqld
加入开机启动:
[root@master mysql]# chkconfig --list |grep mysqld
[root@master mysql]# chkconfig --add mysqld
[root@master mysql]# chkconfig --list |grep mysqld
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@master mysql]# chkconfig mysqld on
启动mysql:
[root@master mysql]# service mysqld start
Starting MySQL.                                            [  OK  ]
[root@master mysql]# ps aux |grep mysqld


安装apache:
首先解压:

[root@master src]# tar zxvf httpd-2.2.31.tar.gz
配置编译参数:

[root@master src]# cd httpd-2.2.31
[root@master httpd-2.2.31]# ./configure\
--prefix=/usr/local/apache2\
--with-included-apr\
--enable-so\
--enable-deflate=shared\
--enable-expires=shared\
--enable-rewrite=shared\
--with-pcre
上一步编译可能会发生如下错误(如果系统是最小化安装,就会出错)
configure: error: in `/usr/local/src/httpd-2.2.31/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解决办法:
[root@master httpd-2.2.31]# yum install -y gcc
接下来是编译和安装,在进行这一步之前,首先安装几个包:

[root@master httpd-2.2.31]# yum install -y pcre pcre-devel apr apr-devel
然后在进行:
[root@master httpd-2.2.31]# make
[root@master httpd-2.2.31]# make install
上述两个步骤都可以特殊变量"echo $?"查看返回值是否为0,来确定上一步只执行是否正确。

安装php:
[root@master src]# tar jxvf php-5.4.45.tar.bz2
编译:

[root@master src]# cd php-5.4.45
[root@master php-5.4.45]#  ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/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
编译这一步会出现许多错误,这些错误只是因为某些包缺少的缘故,安装上即可:这一步需要安装的包如下:
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libjpeg-devel
安装epel源:
yum install -y epel-release
yum install -y libmcrypt-devel
然后运行make && make install 来完成安装:
拷贝配置文件:
[root@master php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini
至此一个lamp的环境搭建完成,然后就是修改参数,使其能够解析php!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lamp