第一步先安装SQL
1 下载MySQL数据库l到/usr/local/src/
[root@xin tmp]# cd /usr/local/src/
[root@xin src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xuexi src]# du -sh mysql-5.1.73-linux-i686-glibc23.tar.gz
124M mysql-5.1.73-linux-i686-glibc23.tar.gz
2 解压
[root@xin src]# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# du -sh mysql-5.1.73-linux-i686-glibc23
410M mysql-5.1.73-linux-i686-glibc23
3 把解压完的数据移动到/usr/local/mysql
[root@xin src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
4 建立mysql用户
[root@xin src]# useradd -s /sbin/nologin -M mysql
创建一个运行MySQL用户 -s 不登录 -M 不创建家目录
5 初始化数据库
[root@xin src]# cd /usr/local/mysql/
[root@xin mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xin mysql]# mkdir -p /data/mysql
(独立一个/data/分区)
[root@xin mysql]# chown -R mysql /data/mysql/
[root@xin mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
初始化库 --user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。
[root@xuexi mysql]# echo $? (结果为0,说明运行结果正常)
0
6 拷贝配置文件
[root@xuexi mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xuexi mysql]# cd support-files/
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@110 support-files]# cat /etc/my.cnf
(系统创建的配置文件,不需要可以删除)
[root@xuexi support-files]# cp my-large.cnf /etc/my.cnf
7 拷贝启动脚本文件并修改其属性
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@xuexi support-files]# ls /etc/init.d/
abrt-ccpp cgred kdump nfslock restorecond smartd
abrtd cpuspeed killall ntpd rngd sshd
abrt-oops crond lvm2-lvmetad ntpdate rpcbind sssd
acpid cups lvm2-monitor numad rpcgssd sysstat
atd functions mdmonitor oddjobd rpcidmapd udev-post
auditd haldaemon messagebus portreserve rpcsvcgssd winbind
autofs halt netconsole postfix rsyslog ypbind
blk-availability ip6tables netfs psacct sandbox
certmonger iptables network quota_nld saslauthd
cgconfig irqbalance nfs rdisc single
[root@xuexi support-files]# cp mysql.server /etc/init.d/mysqld
[root@xuexi support-files]# vi /etc/init.d/mysqld
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/data/mysql/
[root@xuexi support-files]#ll /etc/init.d/mysqld (查看权限)
-rwxr-xr-x. 1 root root 12511 4月 8 17:00 /etc/init.d/mysqld
9 把启动脚本加入系统服务项,并设定开机启动,启动mysql
[root@xuexi support-files]# chkconfig --add mysqld
[root@xuexi support-files]# chkconfig mysqld on
[root@xuexi support-files]# chkconfig --list |grep mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@xuexi support-files]# /etc/init.d/mysqld start
Starting MySQL.... [确定]
第二步安装PHP
下载PHP
[root@lnmp src]# wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
解压
[root@lnmp src]# tar -jxvf php-5.4.37.tar.bz2
创建相关账户
[root@lnmp src]# useradd -s /sbin/nologin php-fpm
[root@lnmp src]# ls
1.sh nginx-1.8.0 php-5.4.37
mysql-5.1.73-linux-i686-glibc23.tar.gz nginx-1.8.0.tar.gz php-5.4.37.tar.bz2
[root@lnmp src]# cd php-5.4.37
[root@lnmp php-5.4.37]#
安装
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-zend-multibyte \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl
错误:
configure: error: jpeglib.h not found.
解决办法:
[root@xuexi php-5.4.45]# yum install -y gd-devel gd
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
[root@110 src]# wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo
[root@xuexi php-5.4.45]# yum install -y libmcrypt-devel
[root@lnmp etc]#make && make install
修改配置文件
[root@LNMP php-5.4.37]# cp php.ini-production /usr/local/php/etc/php-ini
拷贝配置文件
[root@LNMP php-5.4.37]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
拷贝启动脚本
[root@LNMP php-5.4.37]# vim !$
vim /etc/init.d/php-fpm
[root@LNMP php-5.4.37]# chmod 755 /etc/init.d/php-fpm
赋予执行权限
[root@LNMP php-5.4.37]# chkconfig --add php-fpm
加入到服务列表
[root@LNMP php-5.4.37]# chkconfig php-fpm on
开机启动
[root@LNMP php-5.4.37]# /etc/init.d/php-fpm start
(启动PHP服务)
Starting php-fpm [11-Apr-2016 21:12:08] ERROR: failed to open configuration file '/usr/local /php/etc/php-fpm.conf': No such file or directory (2)
[11-Apr-2016 21:12:08] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm. conf'
[11-Apr-2016 21:12:08] ERROR: FPM initialization failed
failed
[root@LNMP php-5.4.37]# cd /usr/local/php/etc/
[root@LNMP etc]# ls
pear.conf php-fpm.conf.default php-ini
[root@LNMP etc]# mv php-fpm.conf.default php-fpm.conf
拷贝配置文件
[root@LNMP etc]# /usr/local/php/sbin/php-fpm -t
检验错误
[11-Apr-2016 21:13:47] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is su ccessful
[root@LNMP etc]# /etc/init.d/php-fpm start
Starting php-fpm [11-Apr-2016 21:14:10] ERROR: [pool www] cannot get uid for user 'php-fpm'
[11-Apr-2016 21:14:10] ERROR: FPM initialization failed
failed
[root@LNMP etc]# useradd -s /sbin/nologin php-fpm
添加用户
[root@LNMP etc]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@lnmp etc]# ps aux |grep php
查看服务
root 17572 0.0 0.4 29972 2960 ? Ss 02:03 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
php-fpm 17573 0.0 0.4 29972 2644 ? S 02:03 0:00 php-fpm: pool www
php-fpm 17574 0.0 0.4 29972 2644 ? S 02:03 0:00 php-fpm: pool www
[root@lnmp etc]# netstat -lnp
查看端口服务
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 17516/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2445/mysqld
第三步安装nginx
下载
[root@lnmp etc]# cd /usr/local/src/
[root@lnmp src]# wget http://219.239.26.3/files/5000000007B10830/nginx.org/download/nginx-1.6.2.tar.gz
解压
[root@lnmp src]# tar zxvf nginx-1.6.2.tar.gz
[root@lnmp src]# cd nginx-1.6.2
[root@lnmp nginx-1.6.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
安装
[root@lnmp nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre
错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
解决方法:
[root@lnmp nginx-1.6.2]# yum install -y pcre-devel
[root@lnmp nginx-1.6.2]# make install ; echo $?
[root@lnmp nginx-1.6.2]# cd /usr/local/nginx/
[root@lnmp nginx]# ls
conf html logs sbin
[root@lnmp nginx]# ls sbin/nginx
sbin/nginx
[root@lnmp nginx]# /usr/local/nginx/sbin/nginx
启动nginx服务
[root@lnmp nginx]# ps aux |grep nginx
root 20831 0.0 0.1 5300 628 ? Ss 02:25 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 20832 0.0 0.1 5484 992 ? S 02:25 0:00 nginx: worker process
root 20834 0.0 0.1 5980 760 pts/0 S+ 02:26 0:00 grep nginx
[root@lnmp nginx]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 17572/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2445/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1025/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20831/nginx
1 下载MySQL数据库l到/usr/local/src/
[root@xin tmp]# cd /usr/local/src/
[root@xin src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xuexi src]# du -sh mysql-5.1.73-linux-i686-glibc23.tar.gz
124M mysql-5.1.73-linux-i686-glibc23.tar.gz
2 解压
[root@xin src]# tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# ls
mysql-5.1.73-linux-i686-glibc23
mysql-5.1.73-linux-i686-glibc23.tar.gz
[root@xin src]# du -sh mysql-5.1.73-linux-i686-glibc23
410M mysql-5.1.73-linux-i686-glibc23
3 把解压完的数据移动到/usr/local/mysql
[root@xin src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql
4 建立mysql用户
[root@xin src]# useradd -s /sbin/nologin -M mysql
创建一个运行MySQL用户 -s 不登录 -M 不创建家目录
5 初始化数据库
[root@xin src]# cd /usr/local/mysql/
[root@xin mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xin mysql]# mkdir -p /data/mysql
(独立一个/data/分区)
[root@xin mysql]# chown -R mysql /data/mysql/
[root@xin mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
初始化库 --user 定义数据库的所属主, --datadir 定义数据库安装到哪里,建议放到大空间的分区上,这个目录需要自行创建。
[root@xuexi mysql]# echo $? (结果为0,说明运行结果正常)
0
6 拷贝配置文件
[root@xuexi mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xuexi mysql]# cd support-files/
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@110 support-files]# cat /etc/my.cnf
(系统创建的配置文件,不需要可以删除)
[root@xuexi support-files]# cp my-large.cnf /etc/my.cnf
7 拷贝启动脚本文件并修改其属性
[root@xuexi support-files]# ls
binary-configure my-huge.cnf mysqld_multi.server
config.huge.ini my-innodb-heavy-4G.cnf mysql-log-rotate
config.medium.ini my-large.cnf mysql.server
config.small.ini my-medium.cnf ndb-config-2-node.ini
magic my-small.cnf
[root@xuexi support-files]# ls /etc/init.d/
abrt-ccpp cgred kdump nfslock restorecond smartd
abrtd cpuspeed killall ntpd rngd sshd
abrt-oops crond lvm2-lvmetad ntpdate rpcbind sssd
acpid cups lvm2-monitor numad rpcgssd sysstat
atd functions mdmonitor oddjobd rpcidmapd udev-post
auditd haldaemon messagebus portreserve rpcsvcgssd winbind
autofs halt netconsole postfix rsyslog ypbind
blk-availability ip6tables netfs psacct sandbox
certmonger iptables network quota_nld saslauthd
cgconfig irqbalance nfs rdisc single
[root@xuexi support-files]# cp mysql.server /etc/init.d/mysqld
[root@xuexi support-files]# vi /etc/init.d/mysqld
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/data/mysql/
[root@xuexi support-files]#ll /etc/init.d/mysqld (查看权限)
-rwxr-xr-x. 1 root root 12511 4月 8 17:00 /etc/init.d/mysqld
9 把启动脚本加入系统服务项,并设定开机启动,启动mysql
[root@xuexi support-files]# chkconfig --add mysqld
[root@xuexi support-files]# chkconfig mysqld on
[root@xuexi support-files]# chkconfig --list |grep mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@xuexi support-files]# /etc/init.d/mysqld start
Starting MySQL.... [确定]
第二步安装PHP
下载PHP
[root@lnmp src]# wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
解压
[root@lnmp src]# tar -jxvf php-5.4.37.tar.bz2
创建相关账户
[root@lnmp src]# useradd -s /sbin/nologin php-fpm
[root@lnmp src]# ls
1.sh nginx-1.8.0 php-5.4.37
mysql-5.1.73-linux-i686-glibc23.tar.gz nginx-1.8.0.tar.gz php-5.4.37.tar.bz2
[root@lnmp src]# cd php-5.4.37
[root@lnmp php-5.4.37]#
安装
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--enable-zend-multibyte \
--disable-ipv6 \
--with-pear \
--with-curl \
--with-openssl
错误:
configure: error: jpeglib.h not found.
解决办法:
[root@xuexi php-5.4.45]# yum install -y gd-devel gd
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决办法:
[root@110 src]# wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-6.repo
[root@xuexi php-5.4.45]# yum install -y libmcrypt-devel
[root@lnmp etc]#make && make install
修改配置文件
[root@LNMP php-5.4.37]# cp php.ini-production /usr/local/php/etc/php-ini
拷贝配置文件
[root@LNMP php-5.4.37]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
拷贝启动脚本
[root@LNMP php-5.4.37]# vim !$
vim /etc/init.d/php-fpm
[root@LNMP php-5.4.37]# chmod 755 /etc/init.d/php-fpm
赋予执行权限
[root@LNMP php-5.4.37]# chkconfig --add php-fpm
加入到服务列表
[root@LNMP php-5.4.37]# chkconfig php-fpm on
开机启动
[root@LNMP php-5.4.37]# /etc/init.d/php-fpm start
(启动PHP服务)
Starting php-fpm [11-Apr-2016 21:12:08] ERROR: failed to open configuration file '/usr/local /php/etc/php-fpm.conf': No such file or directory (2)
[11-Apr-2016 21:12:08] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm. conf'
[11-Apr-2016 21:12:08] ERROR: FPM initialization failed
failed
[root@LNMP php-5.4.37]# cd /usr/local/php/etc/
[root@LNMP etc]# ls
pear.conf php-fpm.conf.default php-ini
[root@LNMP etc]# mv php-fpm.conf.default php-fpm.conf
拷贝配置文件
[root@LNMP etc]# /usr/local/php/sbin/php-fpm -t
检验错误
[11-Apr-2016 21:13:47] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is su ccessful
[root@LNMP etc]# /etc/init.d/php-fpm start
Starting php-fpm [11-Apr-2016 21:14:10] ERROR: [pool www] cannot get uid for user 'php-fpm'
[11-Apr-2016 21:14:10] ERROR: FPM initialization failed
failed
[root@LNMP etc]# useradd -s /sbin/nologin php-fpm
添加用户
[root@LNMP etc]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@lnmp etc]# ps aux |grep php
查看服务
root 17572 0.0 0.4 29972 2960 ? Ss 02:03 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
php-fpm 17573 0.0 0.4 29972 2644 ? S 02:03 0:00 php-fpm: pool www
php-fpm 17574 0.0 0.4 29972 2644 ? S 02:03 0:00 php-fpm: pool www
[root@lnmp etc]# netstat -lnp
查看端口服务
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 17516/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2445/mysqld
第三步安装nginx
下载
[root@lnmp etc]# cd /usr/local/src/
[root@lnmp src]# wget http://219.239.26.3/files/5000000007B10830/nginx.org/download/nginx-1.6.2.tar.gz
解压
[root@lnmp src]# tar zxvf nginx-1.6.2.tar.gz
[root@lnmp src]# cd nginx-1.6.2
[root@lnmp nginx-1.6.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
安装
[root@lnmp nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre
错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
解决方法:
[root@lnmp nginx-1.6.2]# yum install -y pcre-devel
[root@lnmp nginx-1.6.2]# make install ; echo $?
[root@lnmp nginx-1.6.2]# cd /usr/local/nginx/
[root@lnmp nginx]# ls
conf html logs sbin
[root@lnmp nginx]# ls sbin/nginx
sbin/nginx
[root@lnmp nginx]# /usr/local/nginx/sbin/nginx
启动nginx服务
[root@lnmp nginx]# ps aux |grep nginx
root 20831 0.0 0.1 5300 628 ? Ss 02:25 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 20832 0.0 0.1 5484 992 ? S 02:25 0:00 nginx: worker process
root 20834 0.0 0.1 5980 760 pts/0 S+ 02:26 0:00 grep nginx
[root@lnmp nginx]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 17572/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2445/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1025/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20831/nginx
编辑回复