The flow this time is roughly in the order of OpenSSL, Apache Subversion, APR, APR-util, PCRE ,, Apache2 (httpd), PHP. We will use different packages and builds as appropriate.
environment | |
---|---|
OS | Ubuntu server 20.04 |
CPU | Intel Core i5 2500 |
memory | 4GB(DDR3) |
Network | LAN |
version | 2020/09/01 as of the latest |
---|---|
httpd | 2.4.26 |
OpenSSL | 1.1.1g |
PHP | 7.4.9 |
sudo apt update -y && sudo apt upgrade -y
sudo apt install build-essential
sudo apt purge openssl
sudo apt purge apache2
Build Install Porg, which can manage the installed software. For more details, check out this article. (https://qiita.com/ksugawara61/items/38fe9d8e2cc444639fe0)
Latest: https://sourceforge.net/projects/porg/files/
cd /usr/local/src
sudo wget http://sourceforge.net/projects/porg/files/porg-0.10.tar.gz/download -O porg-0.10.tar.gz --no-check-certificate
sudo tar xvf porg-0.10.tar.gz && cd porg-0.10
sudo ./configure --prefix=/usr/local --disable-grop
sudo make && sudo install
Latest: https://zlib.net/
cd /usr/local/src
sudo wget http://www.zlib.net/zlib-1.2.11.tar.gz
sudo tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
sudo ./configure
sudo make
sudo porg -lD "make install"
Latest: https://www.openssl.org/source/
cd /usr/local/src
sudo wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
sudo tar xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
sudo ./config shared zlib
sudo make
sudo porg -lD "make install"
This time apr and apr-util will download the source with apache subversion.
First, install Apache subversion. 1
Then download apr and apr-util. 2 and 3
sudo apt install subversion (1)
sudo svn co https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x/ apr (2)
sudo svn co https://svn.apache.org/repos/asf/apr/apr-util/branches/1.7.x/ apr-util (3)
** The following is a guess, but **
(2 probably checks to see if the required tools are installed. Doing so gave me an unfamiliar error in 3 but ended up not having the required tools installed. It may be possible to prevent it from happening.)
Latest: https://apr.apache.org/anonsvn.html
It's a good idea to have minor versions of apr and apr-util.
cd apr
sudo ./buildconf (2)
sudo ./configure (3)
sudo make
sudo porg -lD "make install"
For example, in my environment, 2 was output as follows. This will quickly tell you which tools are not installed.
buildconf: checking installation...
buildconf: python version 3.8.2 (ok)
buildconf: autoconf not found.
You need autoconf version 2.59 or newer installed
to build APR from SVN.
buildconf: libtool not found.
You need libtool version 1.4 or newer installed
to build APR from SVN.
You can see that you need autoconf
and libtool
. I'm wondering whether to use the package or build from source. After all, I decided to build autoconf
from the package and libtool
from the source.
sudo apt install autoconf
sudo tar xvf libtool-2.4.6.tar.gz
cd libtool-2.4.6
sudo ./configure
sudo make
sudo porg -lD "make install"
Now run 2 again, and if successful, run 3 and beyond, including 3.
Latest: https://apr.apache.org/anonsvn.html
It's a good idea to have minor versions of apr and apr-util.
First, install the required libexpat1-dev
package.
sudo apt install libexpat1-dev -y
Then proceed to build.
cd apr-util
sudo ./buildconf
sudo ./configure --with-apr=/usr/local/apr
sudo make
sudo porg -lD "make install"
Latest: https://www.pcre.org/
Note that it is pcre, not pcre2!
cd /usr/local/src
sudo wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
sudo tar xvf pcre-8.44.tar.gz
cd pcre-8.44
sudo ./configure
sudo make
sudo make install
Latest: https://httpd.apache.org/download.cgi
cd /usr/local/src
sudo apt install libxml2-dev
sudo wget https://downloads.apache.org//httpd/httpd-2.4.46.tar.gz --no-check-certificate
sudo tar xvf httpd-2.4.46.tar.gz
cd httpd-2.4.46
sudo ./configure --enable-ssl --enable-mods-shared=all --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local/pcre-8.44 --with-ssl=/usr/local/ssl --enable-shard=ssl
sudo make
sudo porg -lD "make install"
You can see each directory by the following that appears at the end, so check it.
.
.
.
Installing configuration files
mkdir /usr/local/apache2/conf (configuration file)
.
.
.
Installing HTML documents
mkdir /usr/local/apache2/htdocs (Document root)
.
.
.
Latest: https://www.php.net/downloads
cd /usr/local/src
sudo wget https://www.php.net/distributions/php-7.4.9.tar.gz --no-check-certificate
sudo tar xvf php-7.4.9.tar.gz
cd php-7.4.9
Here is a list of ./configure
options.
--prefix = / opt / php-x.x.x
: Where to install the PHP interpreter and libraries. Bin comes here when using PHP alone.
--with-apxs2
: A script that returns information about Apache2. PHP is required because it is used by embedding it in Apache2.
--enable-mbstring
: Japanese is multi-byte characters, and PHP core does not support multi-byte characters, so specify it because it will be a problem if it happens unexpectedly.
--enable-intl
: Enables various locale-related operations. Formatting, transliteration, encoding conversion, calendar processing, UCA-compliant collation, text delimiters, locale identifiers, time zones and grapheme operations are possible. And in the PHP manual. Enable it. ``
--enable-bcmath
: Enable to perform numerical calculations without error in interactive mode.
~~ --with-pcre-dir
: Specify the same pcre used to build Apache2. ~~
--with-readline
: Doing this will allow the interactive interpreter to be used in PHP, like Python.
--with-libxml-dir
: This specifies the location of the library for XML processing. It is valid by default, but specify which library was built at a glance when you look at the config option later.
Until now, PDO used separate functions prepared for each database to handle databases, so programs written for MySQL could not be used for PostgreSQL without major rewriting.
However, by collecting the differences between each database and using PDO that can be handled uniformly, it becomes possible to operate each database with the same function. To work with databases using PDO, you need a PDO extension and a driver for each database used by PDO.
--with-pdo-mysql
: The PDO extension is enabled by default, so this specifies the MySQL driver that the PDO extension will use. By the way, specify MySQL Native Driver (mysqlnd) for this. If you're dealing with something other than MySQL, see: (https://www.php.net/manual/ja/pdo.drivers.php)
--with-zlib
and --with-zlib-dir
: Specifies zlib, which was also used in OpenSSL (and also used in MySQL builds). Required to use pdo-mysql.
--enable-gd
: Enable GD support. To handle jpeg and png
`sudo apt install libpng-dev libjpeg-dev`
--with-freetype
: freetype2.`sudo apt install freetype-dev`
--with-openssl
: Specify the OpenSSL installation directory so that OpenSSL can also be used from PHP.
with-sodium
: Enable this instead of the deleted mcrypt.
that's all. Next, install the required packages. The number in (x) indicates which extension above is required.
sudo apt install libicu-dev (4)
sudo apt install libreadline-dev (7)
sudo apt install libxml2-dev (8)
sudo apt install libpng-dev libjpeg-dev (11)
sudo apt install libfreetype-dev (12)
sudo apt install libsodium-dev (14)
sudo apt install libsqlite3-dev libonig-dev
Summary
sudo ./configure \
--prefix=/opt/php-7.4.9 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-mbstring \
--enable-intl \
--enable-bcmath \
--with-pcre-regex=/usr/local/lib \
--with-readline \
--with-libxml=/usr/bin/xml2-config \
--with-pdo-mysql=mysqlnd \
--with-zlib=/usr/local \
--with-zlib-dir=/usr/local \
--enable-gd \
--with-freetype \
--with-openssl=/usr/local/ssl \
--with-openssl \
--with-sodium
from here,
sudo make
sudo porg -lD "make install"
The httpd.conf
in the configuration file directory, which was confirmed at the end of the apache2 build, is the configuration file.
The description of Load Module php7_module modules / libphp7.so
in /usr/local/apache2/conf/httpd.conf
is used to incorporate the Apache module of PHP built separately from Apache.
And one more setup is needed to get Apache2 to run PHP. If nothing is done, even if a request comes to .php
, it will return a .php
file like a text file. Therefore, if the requested file is xxxx.php
, add the following description so that it will be executed properly.
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
From (https://www.atmarkit.co.jp/ait/articles/1112/12/news118.html).
Now you're ready to run.
Create the following PHP file under / usr / local / apache2 / htdocs
.
info.php
<?php
phpinfo()
?>
Various commands related to the operation of Apache2 (httpd) are as follows.
Apache2(httpd) | |
---|---|
Start of operation | sudo /usr/local/apache2/bin/apachectl start |
Reboot | sudo /usr/local/apache2/bin/apachectl restart |
Shut down | sudo /usr/local/apache2/bin/apachectl stop |
Use ifconfig
(available with sudo apt install net-tools
) to find the server's private IP address and go to http://192.168.xx/info.php
from a computer in the same network. Please access. Make sure that the configure settings are reflected properly.
You have now installed what you want to install in this article. I would like to use porg -a
to check what I have built so far.
>porg -a
apr
apr-util
httpd-2.4.46
libtool-2.4.6
openssl-1.1.1g
pcre-8.44
php-7.4.9
zlib-1.2.11
https://www.atmarkit.co.jp/ait/series/2540/
https://qiita.com/ksugawara61/items/70f5d1faf192c4ba6ca0
Install Node.js and NPM.
sudo apt install npm nodejs -y
sudo npminstall -g n
sudo n stable
sudo apt purge nodejs npm -y
reboot
node -v
npm -v
If you get npm no such file or ...
, do reboot
and then echo export PATH = / usr / local / bin /: \ $ PATH >> ~ / .bashrc
.
n stable error Reference: (https://stackoverflow.com/questions/36494336/npm-install-error-unable-to-get-local-issuer-certificate)
I will proceed fast from here. For more information, see (https://qiita.com/Suzukaze31/items/3cd7054dd7749d79eb70).
mkdir /usr/local/apache2/htdocs/react-app
chown USER_NAME:USER_NAME -R /usr/local/apache2/htdocs/react-app
npm init -y
sudo npm i -g react react-dom @babel/core @babel/cli @babel/preset-env @babel/preset-react webpack webpack-cli webpack-dev-server babel-loader css-loader style-loader html-webpack-plugin
npm i -save react react-dom
npm i --save-dev @babel/core @babel/cli @babel/preset-env @babel/preset-react webpack webpack-cli webpack-dev-server babel-loader css-loader style-loader html-webpack-plugin
touch webpack.config.js
mkdir src && cd src
touch index.html index.js App.js
index.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="root"></div>
</body>
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />, document.getElementById('root'));
App.js
import React from 'react';
function App() {
return <h1>Hello, World</h1>;
}
export default App;
webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
mode: 'development',
output: {
path: path.resolve(__dirname, './'),
filename: 'bundle.js',
},
module: {
rules: [
{test: /\.(js)$/, use: 'babel-loader'},
{test: /\.css$/, use: ['style-loader', 'css-loader']}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
}
package.json
...
"babel":{
"presets" : [
"@babel/preset-env",
"@babel/preset-react"
]
},
"scripts": {
"build-react-app": "webpack",
"start": "webpack-dev-server --open"
},
...
Now run webpack.
cd /usr/local/apache2/htdocs/react-app
npm run build-react-app
Please access http://192.168.x.x/react-app/
with a web browser. If Hello World is displayed, it's OK.
Recommended Posts