1. The premise of installation: just installed the centos7 system and can connect to the external network to
download all the required installation packages: Link: http://pan.baidu.com/s/1bE5Lb4 Password: of6k
2.
Close the firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #Prohibit firewall from starting
Install iptables firewall
yum install iptables-services #installation
vi /etc/sysconfig/iptables #Edit firewall configuration file
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #Save and exit
systemctl restart iptables.service #Finally restart the firewall to make the configuration take effect
systemctl enable iptables.service #Set the firewall to start at boot
2. Close SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #comment out
#SELINUXTYPE=targeted #Comment out
SELINUX=disabled #Increase
:wq! #Save and exit
setenforce 0 #Make the configuration take effect immediately
3. System agreement
Software source code package storage location: /usr/local/src
Source package compilation and installation location: /usr/local/software name
Fifth, install the compilation tools and library files (use the yum command to install)
yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel --skip-broken
安装篇:
1. Install MySQL
1. Install cmake
cd /usr/local/src
tar zxf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make && make install
2. 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 directly to the system
mkdir -p /data/mysql #Create MySQL database storage directory
chown -R mysql:mysql /data/mysql #Set MySQL database storage directory permissions
mkdir -p /usr/local/mysql #Create MySQL installation directory
cd /usr/local/src #Enter the package storage directory
tar zxf mysql-5.6.15.tar.gz #decompress
cd mysql-5.6.15 #Enter the directory
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #配置
make && make install #安装
rm -rf /etc/my.cnf #Delete the default configuration file of the system (if it does not have it by default, it is not necessary to delete it)
cd /usr/local/mysql #Enter the MySQL installation directory
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #Generate mysql system database
ln -s /usr/local/mysql/my.cnf /etc/my.cnf #Add a soft link to the /etc directory
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #Add Mysql to system startup
chmod 755 /etc/init.d/mysqld #Increase execution permissions
chkconfig mysqld on #Add to boot
vi /etc/rc.d/init.d/mysqld #Edit
basedir=/usr/local/mysql #MySQL program installation path
datadir=/data/mysql #MySQl database storage directory
service mysqld start #start
vi /etc/profile #Add the mysql service to the system environment variable: add the following line at the end
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
The following two lines link the myslq library file to the default location of the system, so that you do not need to specify the mysql library file address when compiling software such as PHP.
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
mkdir /var/lib/mysql #Create directory
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock #Add soft link
mysql_secure_installation #Set the Mysql password, press Y and enter the password twice as prompted
Additional: configure mysql remote access:
Use the root user to log in to mysql on the local machine: mysql -u root -p "youpassword" to authorize the operation:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
service mysqld restart
2. Install Nginx
1. Install pcre
cd /usr/local/src
mkdir /usr/local/pcre
tar zxf pcre-8.35.tar.gz
cd pcre-8.35
./configure --prefix=/usr/local/pcre
make && make install
2. Install openssl
cd /usr/local/src
mkdir /usr/local/openssl
tar zxf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config --prefix=/usr/local/openssl
make && make install
vi /etc/profile
export PATH=$PATH:/usr/local/openssl/bin
:wq!
source /etc/profile
3. Install zlib
cd /usr/local/src
mkdir /usr/local/zlib
tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib
make && make install
4. Install Nginx
groupadd www
useradd -g www www -s /bin/false
cd /usr/local/src
tar zxf nginx-1.6.0.tar.gz
cd nginx-1.6.0
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35
Note: --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src /pcre-8.35 points to the path to decompress the source package, not the path to install, otherwise an error will be reported
make && make install
/usr/local/nginx/sbin/nginx #启动Nginx
关闭nginx:killall nginx
Open the server IP address in the browser, you will see the following interface, indicating that the Nginx installation is successful.
Additional: nginx smooth start command:
/usr/nginx/sbin/nginx -s reload
3. Install php
1. Install yasm
cd /usr/local/src
tar zxf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make && make install
2. Install libmcrypt
cd /usr/local/src
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install
3. Install libvpx
cd /usr/local/src
tar xf libvpx-v1.3.0.tar.bz2
cd libvpx-v1.3.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make && make install
4. Install tiff
cd /usr/local/src
tar zxf tiff-4.0.3.tar.gz
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared
make && make install
5. Install libpng
cd /usr/local/src
tar zxf libpng-1.6.12.tar.gz
cd libpng-1.6.12
./configure --prefix=/usr/local/libpng --enable-shared
make && make install
6. Install freetype
cd /usr/local/src
tar zxf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype --enable-shared
make && make install #安装
7. Install jpeg
cd /usr/local/src
tar zxf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install #安装
8. Install libgd
cd /usr/local/src
tar zxf libgd-2.1.0.tar.gz #decompress
cd libgd-2.1.0 #Enter the directory
./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx #配置 #上述/usr/local/*路径确保有,否则./configure不成功,make回报错
make && make install #安装
9. Install t1lib
cd /usr/local/src
tar zxf t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc
Note that this step may report an error: fatal error: X11/Xaw/Label.h: No such file or directory
Solution: Install libXaw-devel
Run the command: yum install libXaw-devel
make install
10. Install php
Note: If the system is 64-bit, please execute the following two commands, otherwise an error will occur when installing php (32-bit system does not need to be executed)
ln -s /usr/lib64/libltdl.so /usr/lib/libltdl.so
\cp -frp /usr/lib64/libXpm.so* /usr/lib/
cd /usr/local/src
tar -zxf php-5.6.9.tar.gz
cd php-5.6.9
export LD_LIBRARY_PATH=/usr/local/libgd/lib
./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-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype #配置
make && make install #安装
cp php.ini-production /usr/local/php/etc/php.ini #Copy the php configuration file to the installation directory
rm -rf /etc/php.ini #Delete the system's own configuration file
ln -s /usr/local/php/etc/php.ini /etc/php.ini #Add a soft link to the /etc directory
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #Copy template file as php-fpm configuration file
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #Add a soft link to the /etc directory
vi /usr/local/php/etc/php-fpm.conf #Edit
user = www #Set php-fpm running account to www
group = www #Set php-fpm running group to www
pid = run/php-fpm.pid #Cancel the preceding semicolon
:wq! #Save and exit
Set php-fpm to start on boot
cp /usr/local/src/php-5.6.9/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #Copy php-fpm to the startup directory
chmod +x /etc/rc.d/init.d/php-fpm #Add execute permission
chkconfig php-fpm on #Set boot up
vi /usr/local/php/etc/php.ini #Edit configuration file
found: disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#List the functions that PHP can disable. If some programs need to use this function, you can delete and cancel the disable.
found: ;date.timezone=
Modified to: date.timezone = PRC #Set the time zone
:wq! #Save and exit
Configure nginx to support php
vi /usr/local/nginx/conf/nginx.conf
To modify the /usr/local/nginx/conf/nginx.conf configuration file, the following modifications are required
user www www; #Uncomment the first line of user, and modify the Nginx running group to www www; it must be the same as the user and group configuration in /usr/local/php/etc/php-fpm.conf, otherwise PHP will run incorrectly
index index.html index.htm index.php; #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#Cancel the comment of the FastCGI server part of the location, pay attention to the parameter of the fastcgi_param line, change it to $document_root$fastcgi_script_name, or use an absolute path
:wq! #Save and exit
Restart nginx: first execute: killall nginx and then execute: /usr/loca/nginx/sbin/nginx
service php-fpm start #Start php-fpm
Test article
cd /usr/local/nginx/html/ #Enter nginx default website root directory
rm -rf /usr/local/nginx/html/* #delete the default test page
vi index.php #New index.php file
<?php
phpinfo();
?>
:wq! #Save and exit
chown www.www /usr/local/nginx/html/ -R #Set directory owner
chmod 700 /usr/local/nginx/html/ -R #Set directory permissions
Open the server IP address in the browser, you will see the following interface
Test mysql database connection
mysql -uroot -p123456
11. Install redis and php redis extension
Download redis: http://pan.baidu.com/s/1dF3WvU5
cd /usr/local/src/
tar -zxf redis-2.8.17.tar.gz
cd redis-2.8.17/
make
mkdir -p /usr/local/redis
cd /usr/local/src/redis-2.8.17 /src
cp redis-server redis-cli /usr/local/redis/
cd /usr/local/src/redis-2.8.17
cp redis.conf /usr/local/redis/
Modify the redis configuration file to make redis a daemon Run:
/usr/local/redis
vim redis.conf
Change daemonize no to the following image
wq!
Start redis server:
/usr/local/redis/redis-server redis.conf
Test redis:
enter redis-cli:
/usr/local/redis/redis-cli
Redis installation is successful!
12. Install the php redis extension
Download the phpredis extension package, upload it to linux and unzip it:
cd /usr/local/src
tar zxf phpredis.tar.gz
Enter the phpredis source directory to execute a tool in the bin directory of php called phpize:
cd phpredis/
/ usr/local/php/bin/phpize
configure and compile and install phpredis:
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
After installation, it will be in: /usr Generate the redis.so file in the /local/php/lib/php/extensions/no-debug-non-zts-20131226/ directory
Open the php.ini configuration file and add the following:
Restart php-fpm to
service php-fpm restart
to this php redis extension installation is complete!
Additional: install php framework phacon
Note: Link to the original article: http://www.cnblogs.com/moyand/p/5417490.html
The original author is also a great god. On the basis of the original author, combined with my local environment, I have solved some errors encountered during the installation process and recorded them to learn with you.
Composer installs the specified laravel installation version 5.2
|
laravel integrates dingoAPI and ouath2.0
1. Modify composer.json
and run on the command line to composer update
add two packages
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"dingo/api": "1.0.*dev",
"lucadegasperi/oauth2-server-laravel": "5.1.*"
},
2. Add a new one to the config/app.php
fileproviders
/**
* dingoApi and ouath2.0
*/
Dingo\Api\Provider\LaravelServiceProvider::class,
LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider::class,
LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider::class,
aliases
3. Add the following content in
'Authorizer' => LucaDegasperi\OAuth2Server\Facades\Authorizer::class,
app/Http/Kernel.php
4. Add a new $middleware
& in the file$routeMiddleware
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware::class,
];
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'oauth' => \LucaDegasperi\OAuth2Server\Middleware\OAuthMiddleware::class,
'oauth-user' => \LucaDegasperi\OAuth2Server\Middleware\OAuthUserOwnerMiddleware::class,
'oauth-client' => \LucaDegasperi\OAuth2Server\Middleware\OAuthClientOwnerMiddleware::class,
'check-authorization-params' => \LucaDegasperi\OAuth2Server\Middleware\CheckAuthCodeRequestMiddleware::class,
];
5.. Run in the project php artisan vendor:publish
&php artisan migrate
Add these configuration items in.env
API_STANDARDS_TREE=x
API_SUBTYPE=rest
API_NAME=REST
API_PREFIX=api
API_VERSION=v1
API_CONDITIONAL_REQUEST=true
API_STRICT=false
API_DEBUG=true
API_DEFAULT_FORMAT=json