


Deploy php test environment on ubuntu machine, deploy php_PHP tutorial on ubuntu machine
Deploy php test environment on ubuntu machine, deploy php on ubuntu machine
Deploy php test environment on ubuntu machine
1. Deployment environment
Ubuntu11.10_X86_32, compile and install the corresponding software: nginx+mysql+php.
2. Software installation
2.1 Software Download
libiconv-1.14.tar.gz
libmcrypt-2.5.7.tar.gz
mcrypt-2.6.8.gz
mhash-0.9.9.9.tar.gz
mysql-5.5.39.tar.gz
nginx-1.1.10.tar.gz
pcre-8.20.tar.gz
php-5.4.34.tar.gz
2.2 Environment Configuration
If the system is relatively clean, some necessary software tools need to be installed
apt-get install gcc g++ ssh automake cmake build-essential autoconf make re2c wget cron bzip2 rcconf flex vim bison m4 mawk cpp binutils libncurses5 unzip tar libncurses5 libncurses5-dev libtool libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev liblt dl3-dev libpcre3 libpcrecpp0 libssl-dev zlibc openssl libxml2-dev libltdl3-dev libmcrypt-dev
2.3 Auxiliary software installation
2.3.1 libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
cd libiconv-1.14/
./configure --prefix=/usr/local
make
make install
2.3.2 mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install
cd ../
2.3.3 libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
2.3.4 mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
2.3.5 pcre-8.10.tar.gz
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install
2.4 Install mysql
groupadd mysql #Add mysql group
useradd -g mysql mysql -s /bin/false #Create user mysql and add it to the mysql group. Mysql users are not allowed to log in to the system directly
mkdir -p /data/mysql #Create MySQL database storage directory
chown -R mysql:mysql /data/mysql #Set MySQL database directory permissions
tar zxvf mysql-5.5.19.tar.gz
cd mysql-5.5.19
mkdir -p /usr/local/mysql #Create MySQL installation directory
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8-unicode_ci -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CH ARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306
make
make install
cp support-files/my-small.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
/usr/local/mysql/scripts/mysql_install_db --user=mysql
cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf #Copy the configuration file (note: there is a my.cnf under the /etc directory by default, just overwrite it directly)
vi /etc/my.cnf #Edit the configuration file and add
to the [mysqld] sectiondatadir = /data/mysql #Add MySQL database path
./scripts/mysql_install_db --user=mysql #Generate mysql system database
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #Add Mysql to the system startup
chmod 755 /etc/init.d/mysqld #Increase execution permissions
Start: bin/mysqld_safe -user=mysql &
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
Change password/usr/local/mysql/bin/mysqladmin -u root -p password "123456"
Error1:
Solution:
2.5 Install php
apt-get install libfreetype6-dev libjpeg8-dev libpng12-dev slapd ldap-utils db5.1-util
apt-get install libldap2-dev libsasl2-dev
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with- mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem - -enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with- xmlrpc --enable-zip --enable-soap --disable-maintainer-zts
Error 1: configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
Solution: apt-get install curl
apt-get install libcurl4-gnutls-dev
apt-get install php5-curl
Error 2: ldap not found
Solution: Delete ----with-ldap
in the configuration information
make ZEND_EXTRA_LIBS='-liconv'
make test
make install
cp php.ini-production /usr/local/php/etc/php.ini
Execute the command to view PHP related configurations and obtain the extension-dir value of the PHP extension storage directory: /usr/local/php/bin/php-config
The information of extension_dir = is displayed here // http://www.pprar.com
vi /usr/local/php/etc/php.ini
Modify: extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
Create fastcgi configuration file
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
Modify fastcgi configuration file
vi /usr/local/php/etc/php-fpm.conf
Uncomment the following lines
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers
Modify the following two lines of the file. If you start fastcgi without modification, an error will be reported “fastcgi [pool www] cannot get gid for group ‘nobody’”
user = nobody
group = nobody
was changed to
user = www
group = www
Error 1: “fastcgi [pool www] cannot get gid for group ‘www’”
Solution: You need to create users and groups yourself
Sudo useradd www
Start fastcgi
/usr/local/php/sbin/php-fpm
Error2: ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (98)
ERROR: FPM initialization failed
Solution: netstat -lntup | grep 9000
Killall php-fpm
Error3: couldn't load module: /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so : /usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so: cannot open shared object file: No such file or directory
Solution: 1) Install getlibs
Download: getlibs-all.deb
Execution: sudo dpkg -i --force-all getlibs-all.deb
sudo apt-get update getlibs aapt
2) Install 32-bit library
getlibs -p gnome-keyring:i386
3) Generate symbolic link
sudo ln -s /usr/lib32/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so usr/lib/i386-linux-gnu/pkcs11/gnome-keyring-pkcs11.so
2.6 Install Nginx
tar zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module
make
make install
Start Nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Restart the service:/usr/local/nginx/sbin/nginx
Stop service: killall nginx
3. Application deployment
3.1 Environment Deployment
vi /usr/local/nginx/conf/nginx.conf
Add
server {
listen 7070; #External network access port number
server_name blue-desk.com.cn;
location / {
root /usr/local/src/wwwroot; #Application address
index index.html index.htmi index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
root /usr/local/src/wwwroot; #Application address
fastcgi_pass 10.128.7.101:9000; #Port number to contact php-fpm, php-fpm is configured in /usr/local/php/etc/php-fpm.conf
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/src/wwwroot$fastcgi_script_name; #/usr/local/src/wwwroot application location address
include fastcgi_params;
}
}
3.2 Configuration application
onethink application configuration
Database name: mysql
Username: root
Database password: 123456

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools
