LNMP源码编译安装

所用软件:

  nginx-1.4.7.tar.gz

  php-5.4.22.tar.gz

  mysql-5.5.34.tar.gz

  libmcrypt-2.5.7.tar.gz

 

mkdir -pv /opt/app/{nginx,mysql,php}

for i in www mysql;do /usr/sbin/useradd -s /sbin/nologin $i;done


for i in ` rpm -q  make apr* freetype-devel cmake autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch  |grep 'not installed' | awk '{print $2}' `; do yum -y install $i; done 




tar xzf nginx-1.4.7.tar.gz && cd nginx*


./configure --prefix=/opt/app/nginx/ \

> --user=www \

> --group=www \

> --with-http_stub_status_module \

> --with-http_gzip_static_module \

> --with-http_ssl_module \

> --with-pcre


make

make install 

/opt/app/nginx/sbin/nginx -t

nginx: the configuration file /opt/app/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /opt/app/nginx//conf/nginx.conf test is successful




mkdir /opt/app/mysql/data

chown -R mysql.mysql /opt/app/mysql/

tar xzf mysql-5.5.34.tar.gz && cd mysql*


cmake -DCMAKE_INSTALL_PREFIX=/opt/app/mysql \

-DSYSCONFDIR=/opt/app/mysql/etc \

-DMYSQL_DATADIR=/opt/app/mysql/data \

-DMYSQL_TCP_PORT=3306 \

-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \

-DMYSQL_USER=mysql \

-DEXTRA_CHARSETS=all \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1


make

make install 

mkdir /opt/app/mysql/log

mkdir /opt/app/mysql/etc

cp support-files/my-medium.cnf /opt/app/mysql/etc/my.cnf

chmod 755 scripts/mysql_install_db

scripts/mysql_install_db --user=mysql --basedir=/opt/app/mysql/ --datadir=/opt/app/mysql/data/

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:


/opt/app/mysql//bin/mysqladmin -u root password 'new-password'

/opt/app/mysql//bin/mysqladmin -u root -h tools1 password 'new-password'


Alternatively you can run:

/opt/app/mysql//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 /opt/app/mysql/ ; /opt/app/mysql//bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl

cd /opt/app/mysql//mysql-test ; perl mysql-test-run.pl


Please report any problems with the /opt/app/mysql//scripts/mysqlbug script!



mkdir /opt/mysql/init.d

mkdir /opt/app/mysql/init.d

cp support-files/mysql.server /opt/app/mysql/init.d/mysql

chmod a+x /opt/app/mysql/init.d/mysql

/opt/mysql/init.d/mysql start

启动报错StartingMySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/mysql.pid).解决办法:


vim/opt/mysql/etc/my.cnf

[mysqld]下面添加

datadir= /opt/app/mysql/data


chown -R mysql.mysql /opt/app/mysql/data/ 修改所属属性


/opt/app/mysql/init.d/mysql start

Starting MySQL..                                           [  OK  ]




tar xzf libmcrypt-2.5.7.tar.gz && cd libmcrypt*

./configure && make && meke install 




tar xzf php-5.4.22.tar.gz && cd php*



./configure --prefix=/opt//php \

--with-mysql=/opt/app/mysql/ \

--with-mysqli=/opt/app/mysql/bin/mysql_config \

--with-gd --with-iconv --with-freetype-dir  \

--with-png-dir \

--enable-xml \

--enable-fpm \

--with-mcrypt \

--with-curl \

--enable-sockets \

--with-libxml-dir \

--enable-zip \

--with-gettext \

--enable-session


make

make install 

cp php.ini-production /opt/app/php/etc/php.ini





end



后期实现脚本自动安装!

你可能感兴趣的:(编译安装,LNMP)