服务器安装(nginx+php+mysql)

    xiaoxiao2021-03-25  123

    cat /etc/issue CentOS release 6.8 (Final) #安装nginx rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm yum install -y nginx chkconfig nginx on service nginx start cp /etc/nginx/nginx.conf{,.original} vim /etc/nginx/nginx.conf <<VIM > /dev/null 2>&1 :%s/worker_processes  1;/worker_processes  8;/ :%s/worker_connections  1024;/worker_connections  4096;/ :%s/#gzip/server_tokens off;\r    gzip/ :%s/#gzip/gzip/ :wq VIM #安装php-5.5.16 groupadd -g 80 www adduser -o --home /www --uid 80 --gid 80 -c "Web Application" www #后面编译php会提示错误,所以先把问题解决 # configure: error: mcrypt.h not found. Please reinstall libmcrypt. cd /usr/local/src wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5.7.tar.gz cd /usr/local/src/libmcrypt-2.5.7 ./configure --prefix=/usr/local make && make install #configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path yum -y install postgresql-devel #继续安装php yum install -y gcc gcc-c++ make patch \ curl-devel libmcrypt-devel mhash-devel gd-devel libjpeg-devel libpng-devel libXpm-devel libxml2-devel libxslt-devel openssl-devel recode-devel  yum localinstall -y http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum install mysql-community-devel -y yum install -y http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm yum install -y postgresql93-devel cd /usr/local/src/ wget http://cn2.php.net/distributions/php-5.5.16.tar.bz2 tar jxf php-5.5.16.tar.bz2 cd php-5.5.16 ./configure --prefix=/srv/php-5.5.16 \ --with-config-file-path=/srv/php-5.5.16/etc \ --with-config-file-scan-dir=/srv/php-5.5.16/etc/conf.d \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --with-pear \ --with-curl \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-zlib-dir \ --with-iconv \ --with-mcrypt \ --with-mhash \ --with-pdo-mysql \ --with-mysql-sock=/var/lib/mysql/mysql.sock \ --with-mysqli=/usr/bin/mysql_config \ --with-pdo-pgsql=/usr/pgsql-9.3 \ --with-openssl \ --with-xsl \ --with-recode \ --enable-sockets \ --enable-soap \ --enable-mbstring \ --enable-exif \ --enable-gd-native-ttf \ --enable-zip \ --enable-xml \ --enable-bcmath \ --enable-calendar \ --enable-shmop \ --enable-dba \ --enable-wddx \ --enable-sysvsem \ --enable-sysvshm \ --enable-sysvmsg \ --enable-opcache \ --enable-pcntl \ --enable-maintainer-zts \ --with-tsrm-pthreads \ --disable-debug make -j8 make install strip /srv/php-5.5.16/bin/php strip /srv/php-5.5.16/bin/php-cgi mkdir -p /srv/php-5.5.16/etc/conf.d mkdir -p /srv/php-5.5.16/etc/fpm.d cp /srv/php-5.5.16/etc/pear.conf{,.original} cp php.ini-* /srv/php-5.5.16/etc/ cp /srv/php-5.5.16/etc/php.ini-production /srv/php-5.5.16/etc/php.ini cp /srv/php-5.5.16/etc/php.ini-development /srv/php-5.5.16/etc/php.cli.ini cp /srv/php-5.5.16/etc/php-fpm.conf.default /srv/php-5.5.16/etc/php-fpm.conf yes|cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on rm -f /srv/php ln -s /srv/php-5.5.16/ /srv/php vim /srv/php-5.5.16/etc/php-fpm.conf <<end > /dev/null 2>&1 :25,25s/;// :32,32s/;// :93,93s/;rlimit_files = 1024/rlimit_files = 65536/ :225,225s/pm.max_children = 5/pm.max_children = 2048/ :251,251s/;pm.max_requests = 500/pm.max_requests = 1024/ :448,448s/;rlimit_files = 1024/rlimit_files = 40960/ :wq end vim /srv/php-5.5.16/etc/php.ini <<EOF > /dev/null 2>&1 :299,299s$;open_basedir =$open_basedir = /www/:/tmp/:/var/tmp/:/srv/php-5.5.16/lib/php/:/srv/php-5.5.16/bin/$ :366,366s/expose_php = On/expose_php = Off/ :396,396s/memory_limit = 128M/memory_limit = 32M/ :758,758s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/ :913,913s:;date.timezone =:date.timezone = Asia/Hong_Kong: :1390,1390s:;session.save_path = "/tmp":session.save_path = "/dev/shm": :1416,1416s/session.name = PHPSESSID/session.name = JSESSIONID/ :wq EOF vim /srv/php-5.5.16/etc/php.cli.ini <<EOF > /dev/null 2>&1 :396,396s/memory_limit = 128M/memory_limit = 4G/ :575,575s/;// :913,913s:;date.timezone =:date.timezone = Asia/Hong_Kong: :wq EOF cat >> ~/.bashrc <<'EOF' alias php='php -c /srv/php/etc/php.cli.ini' PATH=$PATH:/srv/php/bin EOF /etc/init.d/php-fpm start #安装mysql yum localinstall -y http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum update -y yum install mysql-server -y chkconfig mysqld on service mysqld start cp /etc/my.cnf{,.original} cat >> /etc/security/limits.d/80-mysql.conf <<EOF mysql soft nofile 40960 mysql hard nofile 40960 EOF cat >> /etc/my.cnf.d/default.cnf <<EOF [mysqld] skip-name-resolve max_connections=8192 default-storage-engine=INNODB #wait_timeout=30 #interactive_timeout=30 character-set-server=utf8 collation_server=utf8_general_ci init_connect='SET NAMES utf8' explicit_defaults_for_timestamp=true query_cache_type=1 query_cache_size=512M [client] character_set_client=utf8 EOF mysql -u root mysql> set password for root@localhost=password('v612WJy75SCJ419OR0HuISSLF96bVIsJ'); select version(); +-----------+ | version() | +-----------+ | 5.6.35  mysql> select Host,User,Password from mysql.user; mysql> delete from mysql.user where Password='';
    转载请注明原文地址: https://ju.6miu.com/read-9884.html

    最新回复(0)