TMM 发表于 2013-10-9 16:20:13

CentOS下手把手安装LNMP

我的系统之前装的是Ubuntu的,安装PMTA的时候,老是报错,后来在朋友的VPS上试一下(系统是Centos),可以安装成功。一气之下,又找了一台电脑,安装了一个Centos系统。

本次安装的系统版本是:CentOS release 6.2 Final
Kernel 2.6.32-220.e16.x84_64
安装的时候选择的是最小化安装

之后配置IP,更新软件,然后终于到了安装LNMP的步骤了。

下面说一下详细的安装过程,要有点耐心哟。

安装前先更新相关软件yum -y install pcre-develzlib-devel install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel编译安装PHP5.4.19所需的支持库tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install

---
cd ..
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install

---
cd ../..
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.7 /usr/lib/libmcrypt.so.4.4.7
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

---
cd ..
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install

---
cd ..
tar zxvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make && make install
cp /usr/local/bin/cmake /usr/bin/
cd ..
安装mysqlgroupadd mysqluseradd -g mysql -s /usr/sbin/nologin mysql
mkdir -p /usr/local/webserver/mysql/data
tar zxvf mysql-5.5.27.tar.gz
cd mysql-5.5.27
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql -DMYSQL_DATADIR=/usr/local/webserver/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
make && make istall复制配置文件cp support-files/my-medium.cnf/etc/my.cnf设置权限chmod +x /usr/local/webserver/mysql
chown -R mysql:mysql /usr/local/webserver/mysql/
chown -R mysql:mysql /usr/local/webserver/mysql/data初始化数据库/usr/local/webserver/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data配置开机自启动cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld strat 或 service mysqld start进入数据库ln -s /usr/local/webserver/mysql/bin/mysql /usr/bin/
mysql –uroot –p
Enter password:
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.27-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.设置密码mysql> set password=password('123');
Query OK, 0 rows affected (0.00 sec)添加远程登录账号mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)
刷新数据库mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)关闭防火墙Service iptables stop这样就可以远程登录了,可以在客户端测试一下是否能正常连接telnet 192.168.1.10 3306安装PHPcd ..
tar zxvf php-5.4.19.tar.gz
cd php-5.4.19
./configure --prefix=/usr/local/webserver/php \
--with-config-file-path=/usr/local/webserver/php/etc \
--with-mysql=/usr/local/webserver/mysql \
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config \
--with-iconv-dir=/usr/local \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-ldap \
--with-ldap-sasl \
--with-xmlrpc \
--enable-zip \
--enable-soap安装的过程中可能会出现:configure: error: Cannot find ldap libraries in /usr/lib解决办法:cp -frp /usr/lib64/libldap* /usr/lib/
ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib64/cp php.ini-production /usr/local/webserver/php/etc/php.ini
cp /usr/local/webserver/php/etc/php-fpm.conf.default /usr/local/webserver/php/etc/php-fpm.conf编译安装PHP5扩展模块tar zxvf memcache-2.2.6.tgz
cd memcache-2.2.6
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ..

安装libmemcached
tar zxvf libmemcached-1.0.14.tar.gz
cd libmemcached-1.0.14
./configure --prefix=/usr/local/webserver/libmemcached --with-memcached
make && make install

php的扩展memcached的安装
tar zxvf memcached-2.1.0.tgz
cd memcached-2.1.0
/usr/local/webserver/php/bin/phpize
./configure --enable-memcached --with-libmemcached-dir=/usr/local/webserver/libmemcached --prefix=/usr/local/webserver/memcached --with-php-config=/usr/local/webserver/php/bin/php-config
make && make install
cd ..

tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config \
--with-pdo-mysql=/usr/local/webserver/mysql/
ln -s /usr/local/webserver/mysql/include/* /usr/local/include/
make
make install
cd ..

tar zxvf ImageMagick-6.7.8-2.tar.gz
cd ImageMagick-6.7.8-2
./configure
make
make install
cd ..

tar zxvf imagick-3.1.2.tgz
cd imagick-3.1.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
cd ..

---
groupadd www
useradd -g www -s /usr/sbin/nologin www
修改php.ini文件
手工修改:查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"修改为
extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20100525"
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "memcached.so"
extension = "pdo_mysql.so"
extension = "imagick.so"

---
php-fpm 启动:
/usr/local/webserver/php/sbin/php-fpm
php-fpm 关闭:
kill -INT `cat /usr/local/webserver/php/var/run/php-fpm.pid`
php-fpm 重启:
kill -USR2 `cat /usr/local/webserver/php/var/run/php-fpm.pid`
查看php-fpm进程数:
ps aux | grep -c php-fpm
安装Nginx所需的pcre库tar zxvf pcre-8.31.tar.gz
cd pcre-8.31
./configure
make
make install安装Nginxtar zxvf nginx-1.5.5.tar.gz
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module --with-http_image_filter_module
make && make install创建Nginx日志目录mkdir -p /data/logs
chmod +w /data/logs
chown -R www:www /data/logs配置文件 关键地方修改如下:server {
    listen       80;
    server_namelocalhost;
    root         /data/www/html;
    index      index.php index.html index.htm;

    location ~ .*\.(php|php5)?$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_indexindex.php;
      fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; #注意此处要记得修改,否则会报错找不到文件
      include      fastcgi_params;
    }
}启动nginx/usr/local/webserver/nginx/sbin/nginx重新启动nginx/usr/local/webserver/nginx/sbin/nginx -s reload至此LNMP配置完成。

PS:为了方便大家下载,我已经把所有用到的安装包放到盘里面了链接:http://pan.baidu.com/s/1uvw5g 密码:gy1q折腾了一下午,终于搞完了。接下来开始配置PMTA,完成后,再给大家分享一下。

严重浪漫 发表于 2013-10-9 16:51:07

坛子里有人分享过,不过楼主的更详细

jeans 发表于 2013-10-9 20:42:57

不错,收藏了。

河小马 发表于 2013-10-9 21:53:59

一直在用ubuntu

平时办公也是ubuntu

感觉很好

TMM 发表于 2013-10-9 22:03:19

河小马 发表于 2013-10-9 21:53 static/image/common/back.gif
一直在用ubuntu

平时办公也是ubuntu


做服务器还是差一些,办公用还可以。

第三层境界 发表于 2013-10-15 14:50:25

tmm这个是安装pmta的必备环境吗?

TMM 发表于 2013-10-15 16:15:13

第三层境界 发表于 2013-10-15 14:50 static/image/common/back.gif
tmm这个是安装pmta的必备环境吗?

如果是用linux服务器的话,就是必须的

第三层境界 发表于 2013-10-15 16:39:18

TMM 发表于 2013-10-15 16:15 static/image/common/back.gif
如果是用linux服务器的话,就是必须的

方便说以下步骤吗?先是安装pmta 然后配置config,下面就是LNMP   还有其他什么需要配置或者安装的吗?我是新手望详细指点。

第三层境界 发表于 2013-10-15 16:40:13

对了 这不是 网站的环境吗跟pmta有什么关系?还是说安装oem需要?

TMM 发表于 2013-10-15 17:00:30

第三层境界 发表于 2013-10-15 16:40 static/image/common/back.gif
对了 这不是 网站的环境吗跟pmta有什么关系?还是说安装oem需要?

oem需要,还有其它第三方的php程序

第三层境界 发表于 2013-10-15 17:23:13

TMM 发表于 2013-10-15 17:00 static/image/common/back.gif
oem需要,还有其它第三方的php程序

pmta配置到哪一步了?方便甩出来看看不

不识拿破仑 发表于 2014-1-15 14:35:16

直接安装一键包呢?

gfyybkj 发表于 2014-7-7 13:36:48

好复杂啊,没点技术不敢嘚瑟,
页: [1]
查看完整版本: CentOS下手把手安装LNMP