Although non-root access, but need to compile php dependencies still need root privileges.
First ensure that linux gcc and g ++ have before installation, because a lot of things need both libraries, and if not, run the following command
yum install -y gcc gcc-c++
General linux which will have, if it already exists, it will be reported that already exists can not be installed
First, install nginx
1. Before installing nginx, we need to install three dependencies zlib, pcre, openssl (this requires root privileges)
yum install -y zlib pcre openssl
2. If not yum, it is an external download zlib, pcre, openssl dependencies and then install the above, yum if successful, skip this step
2.1 install pcre (time to make this requires root privileges)
Download pcre dependencies ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre
// uploaded to the directory here directory / home / nginx / (is nginx user)
cd /home/nginx/
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make
make install
2.2 install openssl (time to make this requires root privileges)
Download openssl dependencies http://distfiles.macports.org/openssl/
uploaded to the directory // here directory / home / nginx / (is nginx user)
cd /home/nginx/
tar -zxvf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config
make
make install
2.3 install zlib (time to make this requires root privileges)
Download zlib dependencies http://www.zlib.net/fossils/
uploaded to the directory // here directory / home / nginx / (is nginx user)
cd /home/nginx/
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
CFLAGS="-O3 -fPIC" ./configure
make
make install
3. Install nginx
Download nginx http://nginx.org/en/download.html
uploaded to the directory // here directory / home / nginx / (is nginx user)
Nginx-1.8.0.tar.gz -zxvf the tar
CD Nginx-1.8.0
./configure --prefix = / Home / Nginx / Nginx-Server // - prefix = directory to install
the make
the make the install
// if there is a second operating step, when the mounting nginx, use the following configuration command, as in the rest of the command
./configure --prefix = / home / nginx / nginx-server --with-pcre = / home /nginx/pcre-8.36 --with-zlib = / home / nginx / zlib-1.2.3 --with-openssl = / home / nginx / openssl-1.0.1e
// - with-pcre = pcre installation path address --with-zlib = zlib installation path address --with-openssl = openssl installation path address
4. Check whether nginx successful
cd / Home / nginx / nginx-Server / sbin
./nginx -v view the version, testing whether the installation is successful
Two install mysql
1. Before installing mysql install cmake gadgets, use cmake to compile (this requires root privileges)
yum install -y cmake
2. If the above can not yum, it is an external download cmake install, yum if successful, skip this step (make when this requires root privileges)
Download cmake https://cmake.org/files/
// uploaded to the directory here directory / home / mysql / (a mysql user)
cd /home/mysql/
tar -xvzf cmake-3.6.1.tar.gz
cd cmake-3.6.1
./bootstrap
gmake
make install
3. Install mysql
Download MySQL http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
// uploaded to the directory here directory / home / mysql / (a mysql user)
tar -zxvf mysql-5.6.43.tar.gz
cd mysql-5.6.43
cmake -DCMAKE_INSTALL_PREFIX = / Home / mysql / mysql-Server // - DCMAKE_INSTALL_PREFIX = directory you want to install
the make
the make install
Configuring mysql
cd / Home / mysql / mysql-Server
RM -f /etc/my.cnf // delete the system comes with mysql configuration file
./scripts/mysql_install_db
Copy ./support-files/mysql.server /etc/init.d/ to the
cp support-files / mysql.server /etc/init.d/mysqld
Linux modify environment variables
vim / etc / profile // vim does not work you can use the vi command
Move the cursor to the last line, and then i will be operated in the last line write, then the final addition of / etc / profile file an
export PATH = "/ home / mysql / mysql-server / bin: $ PATH"
and then press live "Esc" to exit the current write operation, and then pressed the "Shift" + ":" and enter "wq" to save and exit
source / etc / profile // this one is to make the configuration take effect immediately
service mysqld start // start mysql
Here you can operate the database
5. Modify the database password
the root -p -u MySQL
// password is empty, where it is directly hit enter a password to
use mysql; // Select Database
UPDATE user SET password = PASSWORD ( ' newpasswd') WHERE user = 'root'; / / change the password, which is the newpasswd you want to set a password
flush privileges; // refresh, setting up the need to refresh to take effect
exit; // exit
Third, install php
1. yum install php compilation process needed to build tools and applets (small install these compilation tools and procedures need root privileges)
yum install -y autoconf libtool-ltdl-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel ncurses-devel libcap-devel sendmail pcre-devel libxslt-devel bzip2-devel diffutils unzip ntp bzip2 patch curl libjpeg libpng freetype libxslt libxml2 libxml2-devel
// is recommended to install one by one, to prevent errors
2. If the first step in libxml2 can not be installed, please download external dependencies and install libxml2, if already installed libxml2, skip this step
Installation libxml2 (libxml2 installation must root privileges)
Download libxml2 http://xmlsoft.org/sources/
uploaded to the directory // here directory / home / php / (php is the user, the user is not necessarily the php user, other users may be, that is for other users the corresponding user name directory, because linux is created when the user will have the corresponding file in the directory / home directory, the user shall we use to operate in the corresponding directory, the company operates in accordance with user set)
cd /home/php/
tar -zxvf libxml2-2.9.1.tar.gz
cd libxml2-2.9.1
./configure--with-python=no
make
make install
3. Install php
Download PHP https://museum.php.net/php5/
// uploaded to the directory here directory / home / php / (php is user)
tar -zxvf php-5.3.27.tar.gz
cd php-5.3.27
./configure --prefix=/home/php/php5 --with-config-file-path=/home/php/php5/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-sockets --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-gd --with-xmlrpc --enable-mbstring --with-curl --enable-ftp --with-mcrypt --without-pear --with-freetype-dir --with-jpeg-dir --with-png-dir --disable-ipv6 --disable-debug --with-openssl //--prefix=要安装的目录
make
make test //test完之后,输入n
make install
// error libmcrypt way possible problems can occur, if there is, download and install libmcrypt, the installation process is as follows :( installation libmcrypt must root privileges)
Download libmcrypt http://soft.7dot.com/
// uploaded to the directory here directory / home / php / (php is user)
CD / Home / PHP /
the tar-2.5.8.tar.gz -zxvf libmcrypt
CD-libmcrypt 2.5.8
./configure --prefix = / usr / local // - prefix = directory to be installed
the make
the make the install
So far, php it installed, the next step is to configure nginx and php
Four, php and nginx configuration
1. php configuration
cp php.ini-development /home/php/php5/etc/php.ini
cp /home/php/php5/etc/php-fpm.conf.default /home/php/php5/etc/php-fpm.conf
vim /home/php/php5/etc/php.ini // vim does not work you can use the vi command
Open the configuration file to find cgi.fix_pathinfo php configuration item, which is a default value of 1 and the comment, in accordance with the official documents described herein for when a file does not exist, sends a request to prevent Nginx PHP-FPM rear end of the module so to avoid malicious script injection attacks, so this should be uncommented and set to 0.
Is set up to save and exit
After // vim or vi configuration file, enter "/cgi.fix_pathinfo/" can be found, if not found, you can enter several times in a row, then the place to find, enter "i" pointer to enter the number of the current row writing mode. After modifying pressed the "Esc" to exit the writing mode, then pressed "Shift" + ":" and enter "wq" to save and exit.
Note that a place is the location of php.ini configuration file can be configured parameter settings before compiling, the compiler parameters can be written: - with-config-file-path = / home / php / php5 / etc so designated on the back of php read directory php.ini configuration file, if not this parameter is the default location lib directory under the php installation directory, concrete can be () output interface to view the phpinfo, if placed in a different location php.ini, php not read to, then all the configuration changes are not in effect, pay attention to this point
vim /home/cib/php/etc/php-fpm.conf
modify php-fpm.conf user and group of users and groups to the corresponding open sites (if opened and the user group is the site www, then nobody will be changed www, where instead Nginx)
User Nginx =
Group = Nginx
Start php-fpm (must root privileges)
/ Home / PHP / php5 / sbin / PHP-FPM
If the ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use error
killall php-fpm
restart start-FPM PHP
/ Home / PHP / php5 / sbin / PHP-FPM
2. nginx configuration
cd nginx-server / conf / (nginx user is, must start nginx nginx user)
vim nginx.conf
Adding nginx.conf upper end of the http {}
include /home/nginx/nginx-server/conf.d/*.conf; // must first create a conf.d directory, * conf is nginx each site profile.
Save and Exit
Then each of the conf.d .conf file directory configuration (here replaced by test.conf)
cd .. // exit the current directory to the previous directory
cd conf.d // into the conf.d directory under this directory
cp /home/nginx/nginx-server/conf/nginx.conf /home/nginx/nginx-server/conf.d/test.conf // nginx.conf copy files to the specified directory and renamed test.conf
vim test.conf // test.conf will delete all directory and writes the following (vim vi command does not work with, such as how to write to save and exit earlier with reference to php.ini configuration and configuration environment variable)
{Server
the listen 80; // external network-connected to the corresponding port number
server_name localhost; // a corresponding domain name, if there is no connection within the network can use the corresponding IP, and port 80 to the other port
root html / test; / / site installation relative path, because it is mounted directly below nginx under the html directory, you can also direct path, website files for the test (test name, site specific file names with the best project related)
index index.html index. htm index.php; // default to open the site page
location ~ \ .php $ {// php module supports the
fastcgi_pass 127.0.0.1:9000;
fastcgi_index the index.php;
fastcgi_param SCRIPT_FILENAME $ $ DOCUMENT_ROOT fastcgi_script_name; // $ DOCUMENT_ROOT front root to the path
the include fastcgi_params;
}
}
// to note here is non-root privileges can not use the following port number 1024
Five test
1. Start nginx (preferably with nginx user)
Enter nginx start address
cd / home / nginx / nginx-server / sbin / // nginx users, directly cd nginx-server / sbin /
./nginx // start nginx
Before starting the first ./nginx recommended configuration file -t view is correct under nginx
./nginx -s reload // restart nginx. If you've started nginx, it should not be used ./nginx command to start, but should use the command here, otherwise there will be a port error
2. Quiz
Write a index.php file in the test directory website
index.php file write the following:
<PHP?
phpinfo ();
?>
Then open the domain name, if you can open the message phpinfo, that php configuration information, it represents the php installation configuration is successful.
// Because here there is not yet binding domain, so only use "IP: Port" to open the way.
So far all over.
The rest of some small things
1. Use the port number, you may encounter a firewall to block that testing sites not open, this time reference https://www.cnblogs.com/chenlizhi/p/6668656.html , set the port number.
2. The port is occupied question, reference https://www.jianshu.com/p/8f6a42fb0654 , or reference https://blog.csdn.net/qq_27252133/article/details/53646986 the second method, a killing process deal with
3. mysql can not be external IP connections, resulting in post-build php sites can not connect to the database, this time reference https://www.cnblogs.com/xiaochongzi/p/6627418.html , set outside the network can be connected.
Installation steps for reference only, linux environment is different, the situation may not be installed as a few dependencies and libraries (that is, you must use root privileges) allows staff to help with root privileges to install, depending on the package you can own path defined as long as it corresponds to the respective dependencies. General production environment without the use of root privileges, because the privileges are too high.
Reference article: https://blog.csdn.net/nouswait/article/details/83105378 primary reference source
https://www.cnblogs.com/freeweb/p/5425554.html secondary reference source
https://blog.csdn.net/hometing218/article/details/79516686 install cmake
https://www.cnblogs.com/nucdy/p/5784809.html modify the database password
https://www.cnblogs.com/Erick-L/p/7066564.html nginx multi-site configuration
https://www.cnblogs.com/ghjbk/p/6728100.html PHP-FPM error problem