linux 安装php mysql nginx

下载地址:

http://museum.php.net/php5/

php: http://cn2.php.net/distributions/php-5.6.9.tar.gz

nginx:http://nginx.org/download/nginx-1.9.1.tar.gz

mysql:http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.20.tar.gz

http://cn2.php.net/distributions/php-5.6.21.tar.gz

http://cn2.php.net/distributions/php-5.6.27.tar.gz

安装步骤:

1.mysql

yum -y install make gcc-c++ cmake bison-devel ncurses-devel bison openssl-devel openssl

cmake \

-DCMAKE_INSTALL_PREFIX=/mnt/mysql \

-DMYSQL_DATADIR=/mnt/mysql/data \

-DSYSCONFDIR=/etc \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_SSL=system \

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

make && make install

groupadd mysql

useradd -g mysql -s /usr/sbin/nologin mysql

//cp /mnt/src/mysql-5.5.20/support-files/my-medium.cnf  /etc/my.cnf

chmod +x /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

chmod +x /mnt/mysql

chown -R mysql:mysql /mnt/mysql

cp support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

/mnt/mysql/scripts/mysql_install_db --user=mysql --basedir=/mnt/mysql --datadir=/mnt/mysql/data & //初始化

ln -s /mnt/mysql/bin/mysql /usr/bin //创建mysql 软连接

use mysql;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

flush privileges;

vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

service  iptables restart

2.nginx

groupadd nginx

useradd -g nginx -s /usr/sbin/nologin nginx

yum  -y install zlib zlib-devel

yum  -y install pcre pcre-devel #支持rewrite

./configure --user=nginx --group=nginx --prefix=/mnt/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_addition_module --with-pcre

make && make install

开机启动

vi /etc/rc.local

最后加入

/mnt/nginx/sbin/nginx -c /mnt/nginx/conf/nginx.conf

vi /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

service  iptables restart

3.php

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

tar -zxvf libmcrypt-2.5.7.tar.gz

cd libmcrypt-2.5.7

./configure --prefix=/usr/local/libmcrypt --disable-posix-threads

make && make install

yum -y install zlib* libxml* ncurses-devel libtool-ltdl-devel* bzip2* libcurl-devel libcurl libjpeg-devel libpng-devel gd-devel gd libpng curl freetype zlib libjpeg openssl openssl-devel

tar -zxvf php-5.5.26.tar.gz

cd php-5.5.26

./configure --prefix=/mnt/php --with-config-file-path=/mnt/php/etc  --enable-mysqlnd --with-mysql --with-mysqli --with-pdo-mysql --with-gd --with-png-dir --with-curl --with-bz2 --with-freetype-dir --with-iconv-dir --with-zlib-dir --enable-soap --with-pear=PREFIX/pear --enable-gd-native-ttf --enable-mbstring --enable-exif --disable-cgi --enable-cli --with-jpeg-dir --enable-bcmath --enable-sockets --disable-ipv6 --with-mcrypt=/usr/local/libmcrypt --enable-fpm --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --enable-shmop --enable-sysvsem  --enable-sysvshm --enable-zip  --disable-fileinfo --enable-opcache --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-curl

make

make install

cp ./php.ini-production /mnt/php/etc/php.ini

cd /mnt/php/etc

cp ./php-fpm.conf.default ./php-fpm.conf

vi /mnt/php/etc/php.ini

include_path = “.:/php/includes”

date.timezone = PRC

session.save_path = "/tmp"

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

你可能感兴趣的:(linux 安装php mysql nginx)