一:安装Nginx
1,添加一个不能登录且没有主目录的用户:
# useradd www -M -s /sbin/nologin(www可以用nginx,说明是nginx用户)
2,必要的组件
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip# unzip pcre-8.13.zip# cd pcre-8.13# ./configure# make && make install
(如果有错误提示:
./configure: error: the HTTP rewrite module requires the PCRE library.请按照下面的安装方法:安装pcre-devel与openssl-devel解决问题
yum -y install pcre-devel openssl openssl-devel)
MGB,安装出现一个问题 make: *** No rule to make targetbuild', needed bydefault'. Stop.,莫名的奇妙;
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++yum -y install openssl openssl-devel
3,编译nginx并安装
# tar -zxvf nginx-1.3.9.tar.gz# cd nginx-1.3.9# ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.34# make && make install --with-pcre 后面的路径 为源码包解压后的路径,而不是安装路径,否则会报错!
[2].安装PHP
1,安装必要的组件
# yum -y install libjpeg-devel libpng-devel# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.8.tar.gz(下载,这个路径不一定正确,可以通过其他方法下载)# tar -zxvf libmcrypt-2.5.8.tar.gz# cd libmcrypt-2.5.8# ./configure# make && make install
==64位系统==
ln -s /usr/lib64/mysql/ /usr/lib/mysql
==64位系统==
2,编译php并安装
# cd php-5.4.9# ./configure --prefix=/opt/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt ='对于libmcrypt的安装目录' --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www# make && make install
相关错误解决:
checking for cURL in default path... not foundconfigure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案: 终端下
# yum -y install curl-devel
然后就可以继续了
在CentOS编译PHP5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决。以下是具体的一些解决办法:
checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distributionFix: yum install bzip2-devel
checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution ? easy.h should be in/include/curl/Fix: yum install curl-devel
checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).Fix: yum install db4-devel
checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.Fix: yum install libjpeg-devel
checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.Fix: yum install libpng-devel
checking for png_write_image in -lpng… yes If configure fails try ?with-xpm-dir= configure: error: freetype.h not found.Fix: Reconfigure your PHP with the following option. --with-xpm-dir=/usr
checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.Fix: yum install libXpm-devel
checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.hFix: yum install gmp-devel
checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.Fix: yum install libc-client-devel
checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.hFix: yum install openldap-devel
checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!Fix:
yum install unixODBC-devel
checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation pathFix: yum install postgresql-devel
checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distributionFix: yum install sqlite-devel
checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspellFix: yum install aspell-devel
checking whether to enable UCD SNMP hack… yes checking for default_store.h… no checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.Fix: yum install net-snmp-devel
checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix: yum install libxslt-devel
configure: error: xml2-config not found. Please check your libxml2 installation.Fix: yum install libxml2-devel
checking for PCRE headers location… configure: error: Could not find pcre.h in /usrFix: yum install pcre-devel
configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!Fix: yum install mysql-devel
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!Fix: yum install unixODBC-devel
checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation pathFix:
yum install postgresql-devel
configure: error: Cannot find pspellFix: yum install pspell-devel
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.Fix: yum install net-snmp-devel
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributionFix: yum install libxslt-devel
3,拷贝和修改php配置文件
# cp php.ini-production /opt/php/lib/php.ini 或是/usr/local/lib/php.ini# cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf# /opt/php/bin/php --ini //测试ini文件是否加载
修改php.ini
[PHP]safe_mode = Onregister_globals = Offmagic_quotes_gpc = Offallow_url_fopen = Offallow_url_include = Offexpose_php=Offdisable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var[Date]date.timezone = “Asia/Shanghai”
修改php-fpm.conf
[global]pid = run/php-fpm.piderror_log = log/php-fpm.loglog_level = noticeemergency_restart_threshold = 0emergency_restart_interval = 0[www]pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35(不能大于max_children)pm.max_requests = 500
4,添加服务启动脚本
# cp nginx /etc/init.d/nginx# cp php-fpm /etc/init.d/php-fpm# chmod 755 /etc/init.d/nginx# chmod 755 /etc/init.d/php-fpm# chkconfig --add nginx# chkconfig --add php-fpm# chkconfig nginx on# chkconfig php-fpm on
三:安装Mysql
3.1, 创建mysql安装目录
mkdir -p /opt/mysql/
3.2, 创建数据存放目录
mkdir -p /data/mysql/
3.3, 创建用户和用户组与赋予数据存放目录权限
# useradd mysql -M -s /sbin/nologin# chown mysql.mysql -R /data/mysql/
3.4, 安装必要的组件
# yum -y install cmake# yum -y install ncurses-devel
3.5, 编译安装Mysql
tar -zxvf mysql-5.5.28.tar.gz cd mysql-5.5.28cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306# make && make install
安装完mysql服务器运行正常,但无法使用gbk字符集,系统装了中文支持,mysql重装了几次都不行.
show character set里没有gbk;
set names gbk 就提示错误 #1115 - Unknown character set: 'gbk'
解决方案:
上面的编译参数-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk这个参数引起的问题方法一、去掉这个参数,默认值是支持all的charset 方法二、直接改为-DWITH_EXTRA_CHARSETS=all加入-DDEFAULT_COLLATION=utf8_general_ci选项后,启动mysql可能会有问题,须在my.cnf 文件 [mysqld]加入character_set_server=utf8
3.6, 初始化数据库
# cd /opt/mysql# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/
3.7, 配置环境
# cp support-files/my-medium.cnf /etc/my.cnf(这里的my.cnf参考服务器的内存大小 一般my-medium.cnf是256M,my-large.cnf是512M)# cp support-files/mysql.server /etc/init.d/mysql# chmod 755 /etc/init.d/mysql# chkconfig mysql on# export PATH=/opt/mysql/bin:$PATH //设置环境变量
3.8, 启动并设置初始密码
# /etc/init.d/mysql start# mysqladmin -uroot password '123123'
进行再修改密码的语句
1: UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新设置密码)2: flush privileges;(刷新权限)
注:mysql日志文件保存在/data/mysql/下面,对应数据文件保存的路径(比如.err)。
四:安装memcached
1.下载libevent和memcached
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gzhttps://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
2.安装libevent
tar -zxvf libevent-2.0.18-stable.tar.gzcd libevent-2.0.18-stable./configure --prefix=/usr/local/libeventmake && make installcd ../
3.安装memcached
tar -zxvf memcached-1.4.13.tar.gzcd memcached-1.4.13./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/make && make installcd ..
4:安装Memcache的PHP扩展
(1).在http://pecl.php.net/package/memcache 选择相应想要下载的memcache版本。 (2).安装PHP的memcache扩展
tar vxzf memcache-2.2.6.tar.gz cd memcache-2.2.6/usr/local/php/bin/phpize ./configure ?enable-memcache ?with-php-config=/usr/local/php/bin/php-config ?with-zlib-dir make make install
(3).上述安装完后会有类似这样的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
(4).把php.ini中的extension_dir = “./”修改为
extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/”
(5).添加一行来载入memcache扩展:extension=memcache.so
5.启动并加入启动项
/usr/local/memcached/bin/memcached -d -l 192.168.1.2 -u www -m 512 -c 10240 -p 12000 -P /tmp/memcached.pid
将以上加入到/etc/rc.local方便下次自动启动 *注:用户-u必须指定,在此处示例所用的是WEB用户www
6.使用telnet查看状态
telnet 192.168.1.2 12000stats #查看运行状态quit #退出
附注:
php5.4.9启动命令:/opt/php/sbin/php-fpm检测php运行进程 ps aux|grep php-fpmphp-fpm 关闭:kill -INT `cat /usr/local/php/var/run/php-fpm.pid`关闭后,需要 /opt/php/sbin/php-fpm启动;没有php-fpm.pid就用touch创建。php-fpm 重启:kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`Nginx 服务启动命令:/opt/nginx/sbin/nginx语法检测 /opt/nginx/sbin/nginx -t 检测nginx.conf文件语法;
php启动报错:
ERROR: [pool www] cannot get uid for user 'fpm'
需要在php-fpm上改动user=fpm group=fpm fpm改成nginx;(安装nginx的用户)

PHP에서, 특성은 방법 재사용이 필요하지만 상속에 적합하지 않은 상황에 적합합니다. 1) 특성은 클래스에서 다중 상속의 복잡성을 피할 수 있도록 수많은 방법을 허용합니다. 2) 특성을 사용할 때는 대안과 키워드를 통해 해결할 수있는 방법 충돌에주의를 기울여야합니다. 3) 성능을 최적화하고 코드 유지 보수성을 향상시키기 위해 특성을 과도하게 사용해야하며 단일 책임을 유지해야합니다.

의존성 주입 컨테이너 (DIC)는 PHP 프로젝트에 사용하기위한 객체 종속성을 관리하고 제공하는 도구입니다. DIC의 주요 이점에는 다음이 포함됩니다. 1. 디커플링, 구성 요소 독립적 인 코드는 유지 관리 및 테스트가 쉽습니다. 2. 유연성, 의존성을 교체 또는 수정하기 쉽습니다. 3. 테스트 가능성, 단위 테스트를 위해 모의 객체를 주입하기에 편리합니다.

SplfixedArray는 PHP의 고정 크기 배열로, 고성능 및 메모리 사용이 필요한 시나리오에 적합합니다. 1) 동적 조정으로 인한 오버 헤드를 피하기 위해 생성 할 때 크기를 지정해야합니다. 2) C 언어 배열을 기반으로 메모리 및 빠른 액세스 속도를 직접 작동합니다. 3) 대규모 데이터 처리 및 메모리에 민감한 환경에 적합하지만 크기가 고정되어 있으므로주의해서 사용해야합니다.

PHP는 $ \ _ 파일 변수를 통해 파일 업로드를 처리합니다. 보안을 보장하는 방법에는 다음이 포함됩니다. 1. 오류 확인 확인, 2. 파일 유형 및 크기 확인, 3 파일 덮어 쓰기 방지, 4. 파일을 영구 저장소 위치로 이동하십시오.

JavaScript에서는 NullCoalescingOperator (??) 및 NullCoalescingAssignmentOperator (?? =)를 사용할 수 있습니다. 1. 2. ??= 변수를 오른쪽 피연산자의 값에 할당하지만 변수가 무효 또는 정의되지 않은 경우에만. 이 연산자는 코드 로직을 단순화하고 가독성과 성능을 향상시킵니다.

CSP는 XSS 공격을 방지하고 리소스로드를 제한하여 웹 사이트 보안을 향상시킬 수 있기 때문에 중요합니다. 1.CSP는 HTTP 응답 헤더의 일부이며 엄격한 정책을 통해 악의적 인 행동을 제한합니다. 2. 기본 사용법은 동일한 원점에서 자원을로드 할 수있는 것입니다. 3. 고급 사용량은 특정 도메인 이름을 스크립트와 스타일로드 할 수 있도록하는 것과 같은보다 세밀한 전략을 설정할 수 있습니다. 4. Content-Security Policy 보고서 전용 헤더를 사용하여 CSP 정책을 디버그하고 최적화하십시오.

HTTP 요청 방법에는 각각 리소스를 확보, 제출, 업데이트 및 삭제하는 데 사용되는 Get, Post, Put and Delete가 포함됩니다. 1. GET 방법은 리소스를 얻는 데 사용되며 읽기 작업에 적합합니다. 2. 게시물은 데이터를 제출하는 데 사용되며 종종 새로운 리소스를 만드는 데 사용됩니다. 3. PUT 방법은 리소스를 업데이트하는 데 사용되며 완전한 업데이트에 적합합니다. 4. 삭제 방법은 자원을 삭제하는 데 사용되며 삭제 작업에 적합합니다.

HTTPS는 HTTP를 기반으로 보안 계층을 추가하는 프로토콜로, 주로 암호화 된 데이터를 통해 사용자 개인 정보 및 데이터 보안을 보호합니다. 작업 원칙에는 TLS 핸드 셰이크, 인증서 확인 및 암호화 된 커뮤니케이션이 포함됩니다. HTTP를 구현할 때는 인증서 관리, 성능 영향 및 혼합 콘텐츠 문제에주의를 기울여야합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

WebStorm Mac 버전
유용한 JavaScript 개발 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

뜨거운 주제



