LNMP编译安装(centos7+nginx1.9+mysql5.6+php5.5)

时间:2023-03-09 00:03:04
LNMP编译安装(centos7+nginx1.9+mysql5.6+php5.5)

LNMP编译安装

# 需先配置IP

# 软件包的路径 /usr/local/src

yum install -y libjpeg-devel libpng-devel freetype-devel curl-devel python-devel curl-devel gcc gcc-c++ bison-devel  ncurses-devel lrzsz openssl-devel libjpeg-devel libpng-devel freetype-devel curl-devel  python-devel  curl-devel

yum install -y libxml2 libxml2-devel cmake

yum -y install openssl openssl-devel libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed

yum install bind-utils





#mysql install

cd /usr/local/src

tar zxvf mysql-5.6.16.tar.gz

cd mysql-5.6.16

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql

make && make install

wget http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.154.tar.gz

tar zxvf Data-Dumper-2.154.tar.gz 

cd Data-Dumper-2.154

yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

perl Makefile.PL

make && make install

groupadd mysql

useradd -r -g mysql mysql

cd /usr/local/mysql

chown -R mysql:mysql .

scripts/mysql_install_db --user=mysql

chown -R root .

chown -R mysql data

#替换配置文件

cp /usr/local/src/my.cnf   /etc/my.cnf  

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

service mysql start

ln -s /usr/local/mysql/bin/mysql /usr/bin/





#nginx 编译

cd /usr/local/src/

tar zxvf zlib-1.2.8

cd zlib-1.2.8

./configure

make && make install





cd /usr/local/src/

tar zxvf nginx-1.9.1.tar.gz

cd nginx-1.9.1

./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid  --lock-path=/var/lock/nginx.lock --user=nginx
--group=nginx --with-http_ssl_module --with-http_spdy_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_stub_status_module --with-http_sub_module --with-http_random_index_module
--with-http_degradation_module --with-http_secure_link_module --with-http_gzip_static_module --with-http_perl_module --with-pcre --with-zlib=/usr/local/src/zlib-1.2.8 --with-debug --with-file-aio --with-mail --with-mail_ssl_module --http-client-body-temp-path=/var/tmp/nginx/client_body
--http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-stream --with-ld-opt="-Wl,-E"

make && make install

# 配置文件替换

cp /usr/local/src/nginx.cnf /etc/nginx/nginx.conf

# 启动NGINX 指定配置文件。VHOST待加入

/usr/sbin/nginx -c /etc/nginx/nginx.conf





#php编译

tar zxvf php-5.5.27.tar.gz 

cd php-5.5.27

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop
--enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session
--with-mcrypt --with-curl --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype

make && make install





# 配置文件替换

cp php.ini-production /usr/local/php/etc/php.ini

ln -s /usr/local/php/etc/php.ini /etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf

/usr/local/php/sbin/php-fpm





#防火墙开启port

firewall-cmd --zone=public --add-port=80/tcp --permanent

firewall-cmd --reload