本次实验中搭建lnmp环境所使用的软件下载http://链接:http://pan.baidu.com/s/1hsCqI5u 密码:ndsy
1:首先要安装的mysql:一般我们把下载的安装包放在/usr/local/src下面:
首先解压安装包:
[[email protected] src]# tar zvxf mysql-5.1.73-linux-i686-glibc23.tar.gz
把解压后的文件移至/usr/local/下:
[[email protected] src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
建立mysql用户,但是用户不能在终端登录(不创建家目录):
[[email protected] src]# useradd -s /sbin/nologin -M mysql
创建数据库文件并且,修改数据库文件权限为mysql!
[[email protected] src]# cd /usr/local/mysql/ [[email protected] mysql]# mkdir -p /data/mysql [[email protected] mysql]# chown -R mysql:mysql /data/mysql
初始化数据库:
[[email protected] 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说明,初始化完成!
拷贝配置文件,如果配置文件已经存在,直接覆盖即可:
[[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf‘? y
拷贝启动脚本,并且修改启动脚步文件权限为755
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld [[email protected] mysql]# chmod 755 !$ chmod 755 /etc/init.d/mysqld
修改启动脚步,把启动脚本中的“datadir=”修改为“datedir = /data/mysql”
[[email protected] mysql]# vim /etc/init.d/mysqld
加入开机启动:
[[email protected] mysql]# chkconfig --list |grep mysqld [[email protected] mysql]# chkconfig --add mysqld [[email protected] mysql]# chkconfig --list |grep mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off [[email protected] mysql]# chkconfig mysqld on
启动mysql:
[[email protected] mysql]# service mysqld start Starting MySQL. [ OK ] [[email protected] mysql]# ps aux |grep mysqld
安装apache:
首先解压:
[[email protected] src]# tar zxvf httpd-2.2.31.tar.gz
配置编译参数:
[[email protected] src]# cd httpd-2.2.31 [[email protected] 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 解决办法: [[email protected] httpd-2.2.31]# yum install -y gcc
接下来是编译和安装,在进行这一步之前,首先安装几个包:
[[email protected] httpd-2.2.31]# yum install -y pcre pcre-devel apr apr-devel
然后在进行:
[[email protected] httpd-2.2.31]# make [[email protected] httpd-2.2.31]# make install
上述两个步骤都可以特殊变量"echo $?"查看返回值是否为0,来确定上一步只执行是否正确。
安装php:
[[email protected] src]# tar jxvf php-5.4.45.tar.bz2
编译:
[[email protected] src]# cd php-5.4.45 [[email protected] 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 来完成安装:
拷贝配置文件:
[[email protected] php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini
至此一个lnmp的环境搭建完成,然后就是修改参数,使其能够解析php!
时间: 2024-08-05 00:01:22